-1

I started learning go and made a crm app, just to find that after building main, it won't run.

This is the error shown in the terminal:

PS crm-go-fiber> go build .\main.go
PS crm-go-fiber> go run .\main.exe
main module (github.com/Lo0mi3x/crm-go-fiber) does not contain package github.com/Lo0mi3x/crm-go-fiber/main.exe

I'm new at programming, GitHub, and stuff but I did my commit & push, and everything correct. Even clone the code from my repository and tried it again, but no changes.

thokuest
  • 5,800
  • 24
  • 36
Diego Cid
  • 17
  • 3
  • 2
    Please stop using file name arguments to go run and go build. Please read and follow the tutorials on go.dev/doc. You _build_ your program by running `go build` (nothing else) and run the generated program via `./crm-go-fiber`. – Volker Jun 16 '23 at 11:05

1 Answers1

1

You're executing your program incorrectly.

go build .\main.go

This command compiles and builds main.go. However, you should generally not pass filenames to go build. The better approach is simply go build. But that's not your actual problem here...

go run .\main.exe

This command attempts to build and run a package called main.exe located in the current directory. The error message you see:

main module (github.com/Lo0mi3x/crm-go-fiber) does not contain package github.com/Lo0mi3x/crm-go-fiber/main.exe

Is telling you that it cannot find a package caleld main.exe within your current package.

If you wish to execute the program you compiled in the first command, just execute it as normal:

.\main.exe
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189