tobychui / arozos

Web Desktop Operating System for low power platforms, Now written in Go!
https://os.aroz.org
GNU General Public License v3.0
2.01k stars 144 forks source link

[BUG] Function redeclaration errors when compiling from source #146

Closed neonspectra closed 10 months ago

neonspectra commented 10 months ago

Describe the bug Attempting to compile ArozOS from source following the "Build from Source" instructions in README.md results in compilation failing with the following error during the go build step:

mod/utils/utils.go:138:6: Templateload redeclared in this block
        mod/utils/template.go:19:6: other declaration of Templateload
mod/utils/utils.go:153:6: TemplateApply redeclared in this block
        mod/utils/template.go:29:6: other declaration of TemplateApply

To Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/tobychui/arozos
  2. cd ./arozos/src/
  3. go mod tidy
  4. go build

At this stage, compilation will interrupt with the error provided above.

Expected behavior ArozOS should compile properly from source.

Screenshots N/A

Host Information:

Client Information: N/A - could not build host

Additional context The error seems to indicate that Go is angry about redeclarations of the same named functions within different files. As a total hack of a workaround, I tried to delete the Templateload and TemplateApply functions out from mod/utils/template.go, port the remaining functions into mod/utils/utils.go, and recompile to bypass the redeclaration errors. However, this resulted in even more redeclaration errors:

# imuslab.com/arozos/mod/agi
mod/agi/externalReqHandler.go:15:6: endpointFormat redeclared in this block
        mod/agi/external.agi.go:15:6: other declaration of endpointFormat
mod/agi/externalReqHandler.go:21:19: method Gateway.ExtAPIHandler already declared at mod/agi/external.agi.go:21:19
mod/agi/externalReqHandler.go:81:19: method Gateway.AddExternalEndPoint already declared at mod/agi/external.agi.go:80:19
mod/agi/externalReqHandler.go:118:19: method Gateway.RemoveExternalEndPoint already declared at mod/agi/external.agi.go:117:19
mod/agi/externalReqHandler.go:156:19: method Gateway.ListExternalEndpoint already declared at mod/agi/external.agi.go:155:19
mod/agi/externalReqHandler.go:200:19: method Gateway.checkIfExternalEndpointExist already declared at mod/agi/external.agi.go:199:19
mod/agi/websocket.go:24:5: upgrader redeclared in this block
        mod/agi/agi.ws.go:24:5: other declaration of upgrader
mod/agi/websocket.go:31:5: connections redeclared in this block
        mod/agi/agi.ws.go:31:5: other declaration of connections
mod/agi/websocket.go:35:6: checkWebSocketConnectionUpgradeStatus redeclared in this block
        mod/agi/agi.ws.go:35:6: other declaration of checkWebSocketConnectionUpgradeStatus
mod/agi/serverlessReqHandler.go:19:19: method Gateway.injectServerlessFunctions already declared at mod/agi/agi.serverless.go:19:19
mod/agi/serverlessReqHandler.go:19:19: too many errors

I don't know Go so please take the following analysis with a grain of salt. I'm almost wondering if there's a language version error from using a feature that isn't available on the version of Go I'm using to build or something like that. However, the README.md lists that I should use Go 1.20+, which I am already doing. Not sure where to go from this.

yeungalan commented 10 months ago

hi we will take a look and check the CICD pipeline, thanks for raising this issue!

Dam-Buty commented 10 months ago

I'm getting the same error on Arch, with compiler go1.21.6

tobychui commented 10 months ago

There are a few files I forgotten to remove before release. It should be working now.

neonspectra commented 10 months ago

Confirmed it's working now after building from eb7f2aee7121fe255f19fd6be884ccbb7b194970. You rock @tobychui!!

Dam-Buty commented 10 months ago

Yes confirmed working on the latest commit !