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 16, 2024
1 parent c53d429 commit 409faf7
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 20 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ require (

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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
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=
Expand All @@ -16,6 +14,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
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=
Expand Down

0 comments on commit 409faf7

Please sign in to comment.