DiagnosticsError codes
M0005 imported and not used
Go rejects imports that the file does not use.
example $ marmot build . error[M0005]: "os" imported and not used --> ./main.go:3:8 | 3 | import "os" // nothing uses os | ^^^^ imported here but not used | = help: if it is imported only for its side effects, write `import _ "os"` error: build failed with 1 error for more about an error, run `marmot explain M0005`
The program that produced it
package main
import "os" // nothing uses os
func main() {}
The mistake and the fix
import "os" // nothing uses os// remove the import, or for side effects only:
import _ "net/http/pprof"The fix
Remove the import, or use _ as its name if it is imported only for its init side effects.
See also all error codes and marmot explain.