8

I'm having some trouble with my go installation in Arch Linux. I installed go a while ago, and haven't touched my installation in a few months. At the time, it was working, however.

When I run the following program, test.go, with go run test.go,

package main

import "fmt"

func main() {
    fmt.Println("Hello World")
}

I get the expected output:

Hello World

However when I try to run the following, Day3.go with go run Day3.go:

package main

import (
    "fmt"
    "os"
    "go"
)

func main() {
    file, err := os.Open("puzzleinput.txt")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Print(file)
}

I get the following error message:

Day3.go:6:2: no Go files in /usr/lib/go/src/go

I also get this error message when trying to use go get and go build. Here's the result of go env (Go is installed under /usr/lib/go):

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ulrich/.cache/go-build"
GOENV="/home/ulrich/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ulrich/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build204360782=/tmp/go-build -gno-record-gcc-switches"

I've also tried uninstalling and reinstalling go, and reconfiguring my GOPATH and GOROOT environment variables to no avail. How can I fix this?

Mahler
  • 81
  • 1
  • 1
  • 2

2 Answers2

2

Don't import the go module. It's not a package:

enter image description here

Ntechhh
  • 58
  • 3
Lucas Katayama
  • 4,445
  • 27
  • 34
1

Delete the "go" import. It's unused.

BasKuunk
  • 21
  • 1
  • 2
    This has already been mentioned in the other answer. – Eric Aya Aug 27 '21 at 13:59
  • No. The other answer says "go" is not a package, but it is in the standard library. It's unused (and should not be used), that's the problem. – BasKuunk Aug 30 '21 at 08:34
  • "Delete the go import" == "Don't import the go module". Same solution ("Do not import the go package", as said in a comment), thus "This has already been mentioned in the other answer". – Eric Aya Aug 30 '21 at 10:55
  • You’re right. It should be a comment on the other answer. – BasKuunk Aug 31 '21 at 11:45