0.187 main.go:4:2: package discorddsb/dsblib is not in std (/usr/local/go/src/discorddsb/dsblib)
0.187 main.go:5:2: package discorddsb/htmlparser is not in std (/usr/local/go/src/discorddsb/htmlparser)
how do i change std to other directory
Assistant
The error messages you're seeing indicate that the Go compiler is looking for the packages discorddsb/dsblib and discorddsb/htmlparser in the standard library directory (/usr/local/go/src/) and not finding them there. This is normal behavior because Go expects external or third-party packages to be in specific locations according to its workspace layout, rather than in the standard library directory.
Rather than trying to change the Go standard library directory (which isn't advisable and isn't necessary), you should follow the Go conventions for package management. Here’s what you can do to resolve these errors:
Using Go Modules
As of Go 1.11 and later, you can utilize Go modules for dependency management, which allow you to work with Go code outside of the GOPATH and manage the versions of the dependencies. If you haven't already, you can initialize a new module:
Initialize the Module:
Navigate to your project's root directory (where your main.go file resides), and then run:
bash
go mod init your-module-name
Add Dependencies:
If discorddsb/dsblib and discorddsb/htmlparser are available publicly, perhaps from a place like GitHub, you can fetch them using go get:
bash
go get github.com/user/discorddsb/dsblib
go get github.com/user/discorddsb/htmlparser
Replace github.com/user with the actual location of the repositories for these packages. After using go get, entries for these packages will be added to your go.mod file, and the packages will be downloaded into your module cache.
Import in Your Code:
Within your main.go, make sure the import statements point to the correct full paths:
Build Your Project:
Finally, from the root of your module (where the go.mod file is located), run:
bash
go build
This command will compile your code, pulling in the dependencies as defined in your go.mod file.
Verify Package Paths
Ensure that the import paths you are using in your Go files correspond exactly to the paths defined in their respective modules or repositories. Mismatched paths or incorrect paths can lead to the errors you are experiencing.
Check GOPATH (For Older Workflow Without Modules)
If you aren't using modules and your project is inside the GOPATH, ensure your dependencies are correctly placed inside the src directory of your GOPATH. However, the recommended approach now is to use Go modules as it simplifies dependency management and you are no longer required to place your project code inside the GOPATH.
These steps should help you configure your Go environment correctly and manage dependencies in your project effectively.