ktateish / gottani

A tool for combining Go source code into a single .go file
BSD 2-Clause "Simplified" License
9 stars 1 forks source link

Error with `missing function body` #6

Open ktateish opened 3 years ago

ktateish commented 3 years ago

Some source has FuncDecl without function body like:

func F(x int) int

This is allowed for using externally defined functions. (see https://golang.org/ref/spec#Function_declarations )

When a function without its body is combined by gottani, it successfully combined to a single .go source but the resulted source cannot be compiled.

$ go build combined.go
# command-line-arguments
golang.org/x/sys/unix/syscall_darwin_libSystem.go:12: missing function body
golang.org/x/sys/unix/syscall_darwin_libSystem.go:13: missing function body
...
ktateish commented 3 years ago

It is hard to handle it with the gottani's approach; "Combining all of the source but standard packages to a single file", because the above case needs assembly source files to compile and there are no proper way to embed assembly source into a .go file. The approach is important for submitting to a judge server in competitive programming contests, my use case.

A obvious workaround is pruning; do not embed the FuncDecl like above and use import "path/to/the/package" instead. But this is in a low priority because it is not my use case.