duanquezhan7268 2017-11-17 09:25
浏览 300
已采纳

错误:输入中出现意外Nul

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\srcuntime\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

  • 写回答

2条回答 默认 最新

  • dragonhong641016 2017-11-17 09:46
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法