Standard library / io/fs
fs.ErrExist
Generic file-already-exists sentinel. Useful for classifying creation conflicts. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrExist errorWorking Example
Example Snippetgo
package main
import ( "errors" "fmt" "io/fs")
func main() { e := &fs.PathError{Op: "create", Path: "x", Err: fs.ErrExist} fmt.Println(errors.Is(e, fs.ErrExist))}