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 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名