+ 2

No Required Module Provides Package

I'm following the steps from a Golang tutorial by FreeCodeCamp. https://youtu.be/YS4e4q9oBaU I'm using go version go1.16.6 windows/amd64. At the part where I want to run "go build github.com/myusername/firstapp" on the VS Code terminal, I got a message saying: no required module provides package github.com/myusername/firstapp: go.mod file not found in current directory or any parent directory; see 'go help modules' In the video tutorial, go.mod wasn't required at all. I did as the message says and ran "go mod init github.com/myusername/firstapp" to create go.mod, but I still received the same message. The same thing happens when I run "go install github.com/myusername/firstapp" I've scoured the Internet for a solution and didn't find one. What is the way to solve this?

25th Jul 2021, 3:51 PM
silentlearner
silentlearner - avatar
1 Resposta
+ 1
To build an executable go requires it to be a package. So, you have to run `go mod init .` or the path. And you also have to set your workspace as a GOPATH See here for more: https://golang.org/doc/gopath_code
30th Jul 2021, 11:42 AM
Rakibul Yeasin
Rakibul Yeasin - avatar