> For the complete documentation index, see [llms.txt](https://close.gitbook.io/yun-wei-bi-ji/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://close.gitbook.io/yun-wei-bi-ji/go/cuo-wu.md).

# 错误

### 无法读取文件'vscode-remote://ssh-remote (Error: 无法解析不存在的文件 'vscode-remote://ssh-remote)

```bash
sudo apt install glibc-source
```

### 报错 package xxx is not in GOROOT or GOPATH

* 例如:

```go
wang@1:~/go$ pwd
/home/wang/go


wang@1:~/go$ ls
bin  pkg  src


wang@1:~/go/src$ tree
.
├── main.go
└── module
    └── module.go


wang@1:~/go/src$ cat module/module.go 
package module

var A string = "aaaa"
```

在GO111MODULE="off"的条件下，并且写的代码不在$GOPATH/src下，也就是说下面的main.go不在$GOPATH/src目录下面，同时我想要使用另一个module里面的内容，并且这个module不是标准库，或者说不在GOROOT里(一般我们不会修改GOROOT中的内容) 运行代码会报错

```go
main.go:4:2: cannot find package "module" in any of:
        /usr/local/go/src/module (from $GOROOT)
        /home/linux/go/src/module (from $GOPATH)
```

**解决方案**

* 设置GOPATH

```go
windows: go env -w GOPATH=/home/wang/go
linux:   export GOPATH=/home/wang/go
```

但是在GO111MODULE="on"的条件下，我们直接调用写好的模块

```go
main.go:5:2: package module is not in GOROOT (/usr/local/go/src/module)
```

**解决方法:**

```go
第一种方式：设置 GO111MODULE="off"，然后像上面的那种方式一样设置GOPATH

第二种方式：使用go mod，如下
go mod init test
import "test/module"         // 然后我们引入模块的时候，以test(初始化时定义)开头，然后接模块路径，比如
```

```go
package main

import (
    "fmt"
    "module"
)

func main() {
    fmt.Println("hello go")
    fmt.Println(module.A)
}


wang@1:~/go/src$ go run main.go 
hello go
aaaa
```

注意: 导入的模块必须使用


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/go/cuo-wu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
