diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ccba3a..1ff8355 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,9 @@ jobs: with: go-version: ${{ env.GO_VERSION }} + - name: Install gotip + run: make gotip + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: diff --git a/.gitignore b/.gitignore index 00e21a6..989f40a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +gopath .gitcookies .idea .vscode/ diff --git a/.golangci.yml b/.golangci.yml index d97a528..12a8210 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -135,6 +135,7 @@ linters: - errchkjson - nonamedreturns - gosmopolitan # not relevant + - gochecknoinits issues: exclude-use-default: false diff --git a/.goreleaser.yml b/.goreleaser.yml index 27a6cb8..07bae7a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,16 +2,15 @@ project_name: plugindemowasm-http-call version: 2 builds: - - binary: plugin.wasm - gobinary: go + - binary: plugin no_unique_dist_dir: true main: . ldflags: - '' - goos: - - wasip1 - goarch: - - wasm + targets: + - wasip1_wasm + buildmode: c-shared + gobinary: ./gopath/bin/gotip changelog: sort: asc diff --git a/Makefile b/Makefile index 30c57d7..55da7d6 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,21 @@ .PHONY: test checks build -export GOOS=wasip1 -export GOARCH=wasm +default: test checks build gotip -default: test checks build +gopath: + mkdir $(CURDIR)/gopath -test: - go test -v -cover ./... +gopath/bin/gotip: gopath + GOPATH=$(CURDIR)/gopath go install golang.org/dl/gotip@latest -build: - @go build -o plugin.wasm ./demo.go +gotip: gopath/bin/gotip + $(CURDIR)/gopath/bin/gotip download + +test: gotip + GOOS=wasip1 GOARCH=wasm $(CURDIR)/gopath/bin/gotip test -v -cover ./... + +build: gotip + GOOS=wasip1 GOARCH=wasm CGO_ENABLED=0 $(CURDIR)/gopath/bin/gotip build -buildmode=c-shared -trimpath -o plugin.wasm ./demo.go checks: - golangci-lint run + GOOS=wasip1 GOARCH=wasm golangci-lint run diff --git a/demo.go b/demo.go index cba3630..a76b081 100644 --- a/demo.go +++ b/demo.go @@ -15,12 +15,13 @@ import ( "github.com/http-wasm/http-wasm-guest-tinygo/handler" "github.com/http-wasm/http-wasm-guest-tinygo/handler/api" - "github.com/juliens/wasm-goexport/guest" _ "github.com/stealthrocket/net/http" "github.com/stealthrocket/net/wasip1" ) -func main() { +func main() {} + +func init() { // Because there is no file mounted in the plugin by default, we configure insecureSkipVerify to avoid having to load rootCas http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec @@ -49,7 +50,6 @@ func main() { os.Exit(1) } handler.HandleRequestFn = mw.handleRequest - guest.SetExports(handler.GetExports()) } // Config the plugin configuration. diff --git a/go.mod b/go.mod index ae29b90..a74753f 100644 --- a/go.mod +++ b/go.mod @@ -6,10 +6,7 @@ toolchain go1.22.4 require ( github.com/http-wasm/http-wasm-guest-tinygo v0.4.0 - github.com/juliens/wasm-goexport v0.0.6 github.com/stealthrocket/net v0.2.1 ) -require github.com/tetratelabs/wazero v1.7.3 // indirect - -replace github.com/http-wasm/http-wasm-guest-tinygo => github.com/juliens/http-wasm-guest-tinygo v0.0.0-20240602204949-9cdd64d990eb +replace github.com/http-wasm/http-wasm-guest-tinygo => github.com/traefik/http-wasm-guest-tinygo v0.0.0-20240913140402-af96219ffea5 diff --git a/go.sum b/go.sum index b027a38..14906bf 100644 --- a/go.sum +++ b/go.sum @@ -1,24 +1,6 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/juliens/http-wasm-guest-tinygo v0.0.0-20240602204949-9cdd64d990eb h1:zu/1V3TubvsyU/7htboUbtJqEjGjiqqb4d2Zw3Y7rNk= -github.com/juliens/http-wasm-guest-tinygo v0.0.0-20240602204949-9cdd64d990eb/go.mod h1:2y41PPhMXqIPjV7avBDtSfiiVcMpYR9UGqFHL0c6dFQ= -github.com/juliens/wasm-goexport v0.0.6 h1:YU0c+j0dF/HNy32vgYTA+K/6wnsZXgGc+ihl/UDw8iA= -github.com/juliens/wasm-goexport v0.0.6/go.mod h1:VTTpJVY3tIBet0Gv8r5TxdsNg0vDkkqXYm0Hp5hR42A= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stealthrocket/net v0.2.1 h1:PehPGAAjuV46zaeHGlNgakFV7QDGUAREMcEQsZQ8NLo= github.com/stealthrocket/net v0.2.1/go.mod h1:VvoFod9pYC9mo+bEg2NQB/D+KVOjxfhZjZ5zyvozq7M= -github.com/stealthrocket/wasi-go v0.8.0 h1:Hwnv3CUoMhhRyero9vt1vfwaYa9tu/Z5kmCW4WeAmVI= -github.com/stealthrocket/wasi-go v0.8.0/go.mod h1:PJ5oVs2E1ciOJnsTnav4nvTtEcJ4D1jUZAewS9pzuZg= -github.com/stealthrocket/wazergo v0.19.1 h1:BPrITETPgSFwiytwmToO0MbUC/+RGC39JScz1JmmG6c= -github.com/stealthrocket/wazergo v0.19.1/go.mod h1:riI0hxw4ndZA5e6z7PesHg2BtTftcZaMxRcoiGGipTs= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw= -github.com/tetratelabs/wazero v1.7.3/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= +github.com/traefik/http-wasm-guest-tinygo v0.0.0-20240913140402-af96219ffea5 h1:D/1vHhfpcbJl6igutIruxClrFwNNogF6ejcu67xzZcw= +github.com/traefik/http-wasm-guest-tinygo v0.0.0-20240913140402-af96219ffea5/go.mod h1:zcKr7h/t5ha2ZWIMwV4iOqhfC/qno/tNPYgybVkn/MQ= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=