go
io_error
ai_generated
true
error: mkdir /path/dir: file exists
ID: go/os-file-already-exists
80%Fix Rate
88%Confidence
0Evidence
2026-08-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.20 | active | — | — | — |
| 1.21 | active | — | — | — |
Root Cause
Attempting to create a directory that already exists, without checking for its existence first.
generic中文
尝试创建已存在的目录,而未先检查其是否存在。
Workarounds
-
98% success Use os.MkdirAll which does not error if exists
if err := os.MkdirAll(path, 0755); err != nil { return err }
Dead Ends
Common approaches that don't work:
-
Ignoring error and continuing
40% fail
May lead to inconsistent state; always handle properly.