Unexpected name main

My .go code has 13187 lines
It always worked well
I have a lot of other go software working fine

Now i’m getting this problem and I could not find in which line the problem is
this problem happened , I update to golang version 1.24.4 windows/amd64
and it continues to happen

A misssing parentheses, perhaps, but I could not find in which line the problem is

go build .

ERROR:

DefAudit/defaudit

.\defaudit.go:6038:6: syntax error: unexpected name main, expected (

PIECES OF MY CODE:
package main
import (
…
)

func … {
…
}

func … {
…
}

func main() {
…
}

It could be many things. According message it seems a ā€œ(ā€ is missing. However you also need to check parameters for calls, brackets balance and so on.
Also it is could be a good idea to refactor and reorganize your code in smaller pieces..

1 Like

Thank you - is there any " golang code analyzer" that could detect which line this missing ā€œ(ā€ is ?

go vet comes bundled when you install go.
Also you can test with StaticCheck (GitHub - dominikh/go-tools: Staticcheck - The advanced Go linter)

1 Like