Hi Bima, prefer text instead of prints. It's faster to help somebody. There's two ways to fix that problem.
1 - You need to use the same module name when import it. As the module name is "main.go" (it's not recommend name like this) you need call it in the import statement like this: import( "fmt" math "main.go/math" ) 2 - You can rename the module name in the go.mod file to golang-book/chapter11 (This module name is better than main.go) and use this name as import to your code. This is an example of how it might be written. chapter11/ └── math └── math.go ├── go.mod ├── main.go go.mod module golang-book/chapter11 go 1.22.0 math.go package math func Average(xs []float64) float64 { total := float64(0) for _, x := range xs { total += x } return total / float64(len(xs)) } main.go package main import ( "fmt" "golang-book/chapter11/math" ) func main() { xs := []float64{1, 2, 3, 4} avg := math.Average(xs) fmt.Println(avg) } Result: 2.5 You can read this great tutorial: https://go.dev/doc/tutorial/create-module. I hope I was able to help you :) Cleberson Pauluci Em segunda-feira, 25 de março de 2024 às 13:25:12 UTC-3, Bima lely escreveu: > Can you help me? i am getting problems when running other program > packages. This error appears *"go: file go.mod not found in current > directory or any parent directory; see 'go help module'", [image: > P3.PNG][image: P5.PNG][image: P4.PNG]* but when I try on my friend's > laptop there is no error. I'm confused. I've been experiencing this for > several weeks. I have attached the file along with a screenshot. Hopefully > someone from my brothers and sisters can help me. Thank You. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/5dc4471d-835c-4c44-992c-f9ce52221d3cn%40googlegroups.com.