Merge pull request #99 from syumai/fix-examples-build

add Makefile command to build example files
This commit is contained in:
syumai 2024-04-17 00:26:11 +09:00 committed by GitHub
commit 9710147e94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 2 deletions

View File

@ -22,4 +22,21 @@ jobs:
- name: Test
shell: bash
run: |
PATH=$PWD/misc/wasm:$PATH GOOS=js GOARCH=wasm go test ./...
PATH=$PWD/misc/wasm:$PATH GOOS=js GOARCH=wasm go test ./...
examples:
name: Build examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Build examples
shell: bash
run: make build-examples

View File

@ -2,3 +2,11 @@
test:
@PATH=$(CURDIR)/misc/wasm:$(PATH) GOOS=js GOARCH=wasm go test ./...
.PHONY: build-examples
build-examples:
for dir in $(shell find ./_examples -maxdepth 1 -type d); do \
if [ $$dir = "./_examples" ]; then continue; fi; \
echo 'build:' $$dir; \
cd $$dir && GOOS=js GOARCH=wasm go build -o ./build/app.wasm; \
cd ../../; \
done

View File

@ -16,7 +16,7 @@ func main() {
bind := cloudflare.GetBinding(ctx, "hello")
fc := fetch.NewClient(fetch.WithBinding(bind))
hc := fc.HTTPClient()
hc := fc.HTTPClient(fetch.RedirectModeFollow)
res, err := hc.Do(req)
if err != nil {
fmt.Println(err)