Home > OS >  Goland shows os.Remove() can't be resolved?
Goland shows os.Remove() can't be resolved?

Time:09-30

In Goland (2022.1.3), using go (1.19.1), it can't resolve os.Remove(), but if I change to os.RemoveAll(), it's ok.

I've checked goland pic


Update: An example code that can run

package main

import (
    "os"
)

func main() {
    os.Create("/tmp/a.txt")
    os.Remove("/tmp/a.txt")
}

The code can run without error, so I think it's goland's bug.

CodePudding user response:

Go introduces a new build tag unix in Go 1.19, but GoLand lower than 2022.2 doesn't support it natively.

  • Update GoLand to 2022.2.3.
  • Alternatively, add unix build tag in Preferences/Settings | Go | Build Tags & Vendoring | Custom tags.
  • Related