golang程序编译时提示“package runtime: unrecognized import path "runtime" (import path does not be

Posted jianyungsun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了golang程序编译时提示“package runtime: unrecognized import path "runtime" (import path does not be相关的知识,希望对你有一定的参考价值。

在编译golang的工程时提示错误的, 提示的错误信息如下:

package bytes: unrecognized import path "bytes" (import path does not begin with hostname)
package encoding/json: unrecognized import path "encoding/json" (import path does not begin with hostname)
package encoding/xml: unrecognized import path "encoding/xml" (import path does not begin with hostname)
package fmt: unrecognized import path "fmt" (import path does not begin with hostname)
package bufio: unrecognized import path "bufio" (import path does not begin with hostname)
package io: unrecognized import path "io" (import path does not begin with hostname)
package strings: unrecognized import path "strings" (import path does not begin with hostname)
package go/ast: unrecognized import path "go/ast" (import path does not begin with hostname)
package go/parser: unrecognized import path "go/parser" (import path does not begin with hostname)
package go/token: unrecognized import path "go/token" (import path does not begin with hostname)
package compress/gzip: unrecognized import path "compress/gzip" (import path does not begin with hostname)
package encoding/hex: unrecognized import path "encoding/hex" (import path does not begin with hostname)
package errors: unrecognized import path "errors" (import path does not begin with hostname)
package strconv: unrecognized import path "strconv" (import path does not begin with hostname)
package encoding: unrecognized import path "encoding" (import path does not begin with hostname)
package text/template: unrecognized import path "text/template" (import path does not begin with hostname)
package encoding/base64: unrecognized import path "encoding/base64" (import path does not begin with hostname)
package math: unrecognized import path "math" (import path does not begin with hostname)
package os: unrecognized import path "os" (import path does not begin with hostname)
package reflect: unrecognized import path "reflect" (import path does not begin with hostname)
package regexp: unrecognized import path "regexp" (import path does not begin with hostname)
package sort: unrecognized import path "sort" (import path does not begin with hostname)
package sync: unrecognized import path "sync" (import path does not begin with hostname)
package time: unrecognized import path "time" (import path does not begin with hostname)
package unicode: unrecognized import path "unicode" (import path does not begin with hostname)
package unicode/utf8: unrecognized import path "unicode/utf8" (import path does not begin with hostname)
package io/ioutil: unrecognized import path "io/ioutil" (import path does not begin with hostname)
package path/filepath: unrecognized import path "path/filepath" (import path does not begin with hostname)
package go/doc: unrecognized import path "go/doc" (import path does not begin with hostname)
package net/url: unrecognized import path "net/url" (import path does not begin with hostname)
package syscall: unrecognized import path "syscall" (import path does not begin with hostname)
package unsafe: unrecognized import path "unsafe" (import path does not begin with hostname)
package os/exec: unrecognized import path "os/exec" (import path does not begin with hostname)
package os/user: unrecognized import path "os/user" (import path does not begin with hostname)
package runtime: unrecognized import path "runtime" (import path does not begin with hostname)
make: *** [Makefile:58:setup] 错误 1

经过最终搜索在github上找到了相对的解决方法:

最终通过执行:unset GOROOT  解决问题;

https://github.com/Rivalo/discord-cli/issues/33

 

以上是关于golang程序编译时提示“package runtime: unrecognized import path "runtime" (import path does not be的主要内容,如果未能解决你的问题,请参考以下文章

C++ 编译时提示:不能将参数 1 从“char [6]”转换为“LPCTSTR”

Golang新起航!(编译安装go)

使用 -ldflags -H=windowsgui 编译 golang 应用程序时将输出打印到命令窗口

golang碎片整理之反射

使用Golang 1.10编译Windows DLL时遇到问题。

VSCode从非根目录编译golang程序