So when I run this program I used to get this error: sample.go:7:2: no required module provides package github.com/go-git/go-git/v5: go.mod file not found in current directory or any parent directory; see 'go help modules'
sample.go:8:2: no required module provides package github.com/go-git/go-git/v5/_examples: go.mod file not found in current directory or any parent directory; see 'go help modules'
Please help me, how I can execute this?
I am using the following: Go version: go version go1.18.1 linux/amd64 Platform: Ubuntu 22.04.1 LTS
peterGo
unread,
Oct 10, 2022, 8:04:28 AM10/10/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Follow the instructions in the error messages: see `go help modules`.
Martin Schnabel
unread,
Oct 10, 2022, 10:06:48 AM10/10/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Hi PK,
most of the time examples are single file programs to be used with go
run. if you are inside the module root that covers all the dependencies
(or decend into the relevant example folder) you can use `go run
main.go` to run the example file.
I just tired it with the same repository and it works as expected and
described.
>
> So when I run this program I used to get this error:
> sample.go:7:2: no required module provides package
> github.com/go-git/go-git/v5: go.mod file not found in current directory
> or any parent directory; see 'go help modules'
>
> sample.go:8:2: no required module provides package
> github.com/go-git/go-git/v5/_examples: go.mod file not found in current
> directory or any parent directory; see 'go help modules'
>
> *Please help me, how I can execute this?*
>
> I am using the following:
> Go version: go version go1.18.1 linux/amd64
> Platform: Ubuntu 22.04.1 LTS
>
Whilst it still does work to say "go run hello.go" for a simple hello-world-and-nothing-else, as soon as it depends on any third-party libraries, it will fail. You *must* include a go.mod file. Then when you import external libraries, "go mod tidy" will fetch them for you, including their dependencies, and update go.mod