Search code examples
go

Go error: unexpected Nul in input


I just installed the go.msi in C:/Go. And I set my Path(C:\Go\bin) and GOPATH(E:\code\go).But when I try to run "go run test.go" I get the following error: test.go:2:8: read C:\Go\src\fmt\export_test.go: unexpected NUL in input package main imports runtime: read C:\Go\src\runtime\export_unix_test.go: unexpected NUL in input
I can not open these files. The code i have is:

    package main

    import "fmt"

    func main()  {
        fmt.Println("Something")
    }

The path of the test.go file is E:\code\go\test.go When i run go env i get:

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\code\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

the output of go version is: go version go1.9.2 windows/amd64


Solution

  • You are missing some things in your GOPATH. You need a folder structure like the following:

    E:\code\go\src\{repository}\{package}\gofile.go
    

    So for this, you could have it be:

    E:\code\go\src\local-only\testing\test.go