Skip to content

Commit 5cbb182

Browse files
authored
switch to official go (master branch) wasmexport
1 parent c53d429 commit 5cbb182

File tree

8 files changed

+30
-41
lines changed

8 files changed

+30
-41
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
with:
2626
go-version: ${{ env.GO_VERSION }}
2727

28+
- name: Install gotip
29+
run: make gotip
30+
2831
- name: Run GoReleaser
2932
uses: goreleaser/goreleaser-action@v6
3033
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
gopath
12
.gitcookies
23
.idea
34
.vscode/

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ linters:
135135
- errchkjson
136136
- nonamedreturns
137137
- gosmopolitan # not relevant
138+
- gochecknoinits
138139

139140
issues:
140141
exclude-use-default: false

.goreleaser.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ project_name: plugindemowasm-http-call
22
version: 2
33

44
builds:
5-
- binary: plugin.wasm
6-
gobinary: go
5+
- binary: plugin
76
no_unique_dist_dir: true
87
main: .
98
ldflags:
109
- ''
11-
goos:
12-
- wasip1
13-
goarch:
14-
- wasm
10+
targets:
11+
- wasip1_wasm
12+
buildmode: c-shared
13+
gobinary: ./gopath/bin/gotip
1514

1615
changelog:
1716
sort: asc

Makefile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
.PHONY: test checks build
22

3-
export GOOS=wasip1
4-
export GOARCH=wasm
3+
default: test checks build gotip
54

6-
default: test checks build
5+
gopath:
6+
mkdir $(CURDIR)/gopath
77

8-
test:
9-
go test -v -cover ./...
8+
gopath/bin/gotip: gopath
9+
GOPATH=$(CURDIR)/gopath go install golang.org/dl/gotip@latest
1010

11-
build:
12-
@go build -o plugin.wasm ./demo.go
11+
gotip: gopath/bin/gotip
12+
$(CURDIR)/gopath/bin/gotip download
13+
14+
test: gotip
15+
GOOS=wasip1 GOARCH=wasm $(CURDIR)/gopath/bin/gotip test -v -cover ./...
16+
17+
build: gotip
18+
GOOS=wasip1 GOARCH=wasm CGO_ENABLED=0 $(CURDIR)/gopath/bin/gotip build -buildmode=c-shared -trimpath -o plugin.wasm ./demo.go
1319

1420
checks:
15-
golangci-lint run
21+
GOOS=wasip1 GOARCH=wasm golangci-lint run

demo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import (
1515

1616
"github.com/http-wasm/http-wasm-guest-tinygo/handler"
1717
"github.com/http-wasm/http-wasm-guest-tinygo/handler/api"
18-
"github.com/juliens/wasm-goexport/guest"
1918
_ "github.com/stealthrocket/net/http"
2019
"github.com/stealthrocket/net/wasip1"
2120
)
2221

23-
func main() {
22+
func main() {}
23+
24+
func init() {
2425
// Because there is no file mounted in the plugin by default, we configure insecureSkipVerify to avoid having to load rootCas
2526
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec
2627

@@ -49,7 +50,6 @@ func main() {
4950
os.Exit(1)
5051
}
5152
handler.HandleRequestFn = mw.handleRequest
52-
guest.SetExports(handler.GetExports())
5353
}
5454

5555
// Config the plugin configuration.

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ toolchain go1.22.4
66

77
require (
88
github.com/http-wasm/http-wasm-guest-tinygo v0.4.0
9-
github.com/juliens/wasm-goexport v0.0.6
109
github.com/stealthrocket/net v0.2.1
1110
)
1211

13-
require github.com/tetratelabs/wazero v1.7.3 // indirect
14-
15-
replace github.com/http-wasm/http-wasm-guest-tinygo => github.com/juliens/http-wasm-guest-tinygo v0.0.0-20240602204949-9cdd64d990eb
12+
replace github.com/http-wasm/http-wasm-guest-tinygo => github.com/traefik/http-wasm-guest-tinygo v0.0.0-20240913140402-af96219ffea5

go.sum

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/juliens/http-wasm-guest-tinygo v0.0.0-20240602204949-9cdd64d990eb h1:zu/1V3TubvsyU/7htboUbtJqEjGjiqqb4d2Zw3Y7rNk=
4-
github.com/juliens/http-wasm-guest-tinygo v0.0.0-20240602204949-9cdd64d990eb/go.mod h1:2y41PPhMXqIPjV7avBDtSfiiVcMpYR9UGqFHL0c6dFQ=
5-
github.com/juliens/wasm-goexport v0.0.6 h1:YU0c+j0dF/HNy32vgYTA+K/6wnsZXgGc+ihl/UDw8iA=
6-
github.com/juliens/wasm-goexport v0.0.6/go.mod h1:VTTpJVY3tIBet0Gv8r5TxdsNg0vDkkqXYm0Hp5hR42A=
7-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
91
github.com/stealthrocket/net v0.2.1 h1:PehPGAAjuV46zaeHGlNgakFV7QDGUAREMcEQsZQ8NLo=
102
github.com/stealthrocket/net v0.2.1/go.mod h1:VvoFod9pYC9mo+bEg2NQB/D+KVOjxfhZjZ5zyvozq7M=
11-
github.com/stealthrocket/wasi-go v0.8.0 h1:Hwnv3CUoMhhRyero9vt1vfwaYa9tu/Z5kmCW4WeAmVI=
12-
github.com/stealthrocket/wasi-go v0.8.0/go.mod h1:PJ5oVs2E1ciOJnsTnav4nvTtEcJ4D1jUZAewS9pzuZg=
13-
github.com/stealthrocket/wazergo v0.19.1 h1:BPrITETPgSFwiytwmToO0MbUC/+RGC39JScz1JmmG6c=
14-
github.com/stealthrocket/wazergo v0.19.1/go.mod h1:riI0hxw4ndZA5e6z7PesHg2BtTftcZaMxRcoiGGipTs=
15-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
16-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
17-
github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw=
18-
github.com/tetratelabs/wazero v1.7.3/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y=
3+
github.com/traefik/http-wasm-guest-tinygo v0.0.0-20240913140402-af96219ffea5 h1:D/1vHhfpcbJl6igutIruxClrFwNNogF6ejcu67xzZcw=
4+
github.com/traefik/http-wasm-guest-tinygo v0.0.0-20240913140402-af96219ffea5/go.mod h1:zcKr7h/t5ha2ZWIMwV4iOqhfC/qno/tNPYgybVkn/MQ=
195
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
206
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
21-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
22-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
23-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
24-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)