Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

go

goland

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 go doc and source code, the function does exists.

So, what's wrong ? Is that a goland bug ?

(BTW, I'm using linux os, if that matters.)


Screenshot (in Goland):

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.

like image 532
user218867 Avatar asked Oct 26 '25 05:10

user218867


1 Answers

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.

If you use IntelliJ with the Go plugin, make sure to upgrade IntelliJ to 2022.2 or above first. It will prompt to upgrade the plugins at the same time.

like image 64
s0xzwasd Avatar answered Oct 28 '25 19:10

s0xzwasd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!