Skip to content

Commit

Permalink
switch to official go (master branch) wasmexport
Browse files Browse the repository at this point in the history
  • Loading branch information
juliens committed Sep 17, 2024
1 parent c53d429 commit 5cbb182
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gopath
.gitcookies
.idea
.vscode/
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ linters:
- errchkjson
- nonamedreturns
- gosmopolitan # not relevant
- gochecknoinits

issues:
exclude-use-default: false
Expand Down
11 changes: 5 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -49,7 +50,6 @@ func main() {
os.Exit(1)
}
handler.HandleRequestFn = mw.handleRequest
guest.SetExports(handler.GetExports())
}

// Config the plugin configuration.
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 2 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=

0 comments on commit 5cbb182

Please sign in to comment.