Skip to content

Commit eea409c

Browse files
opencmit2edsiper
authored andcommitted
examples: filter_wasm_go: Upgrade to support Go 1.22.5 and TinyGo 0.32
Signed-off-by: JinXinWang <[email protected]>
1 parent 03f595b commit eea409c

File tree

4 files changed

+10
-31
lines changed

4 files changed

+10
-31
lines changed

examples/filter_wasm_go/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@ This source source tree provides an example of WASM filter program with WASI mod
77
Tested on
88

99
* TinyGo
10-
* [tinygo](https://tinygo.org/) tinygo version 0.23.0 linux/amd64 (using go version go1.18.2 and LLVM version 14.0.0)
11-
* [tinygo](https://tinygo.org/) tinygo version 0.24.0 linux/amd64 (using go version go1.18.2 and LLVM version 14.0.0)
10+
* [tinygo](https://tinygo.org/) tinygo version 0.32.0 linux/amd64 (using go version go1.22.5 and LLVM version 18.1.2)
1211

1312
For Ubuntu, it's easy to install with:
1413

1514
```console
16-
$ wget https://github.com/tinygo-org/tinygo/releases/download/v0.24.0/tinygo_0.24.0_amd64.deb
17-
$ sudo dpkg -i tinygo_0.24.0_amd64.deb
15+
$ wget https://github.com/tinygo-org/tinygo/releases/download/v0.32.0/tinygo_0.32.0_amd64.deb
16+
$ sudo dpkg -i tinygo_0.32.0_amd64.deb
1817
```
1918

2019
## How to build
2120

2221
Execute _tinygo build_ as follows:
2322

2423
```console
25-
$ tinygo build -wasm-abi=generic -target=wasi -o filter.wasm filter.go
24+
$ tinygo build -target=wasi -o filter.wasm filter.go
2625
```
2726

2827
Finally, under the same directory, `*.wasm` file will be created:
@@ -52,12 +51,12 @@ Create fluent-bit configuration file as follows:
5251
[FILTER]
5352
Name wasm
5453
match dummy.*
54+
Event_Format json
5555
WASM_Path /path/to/filter.wasm
5656
Function_Name go_filter
5757
accessible_paths .,/path/to/fluent-bit
5858

5959
[OUTPUT]
6060
Name stdout
6161
Match *
62-
6362
```

examples/filter_wasm_go/filter.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ func go_filter(tag *uint8, tag_len uint, time_sec uint, time_nsec uint, record *
3131
obj.Set("time", arena.NewString(now.String()))
3232
obj.Set("tag", arena.NewString(string(btag)))
3333
obj.Set("original", arena.NewString(br))
34-
s := obj.String()
35-
s += string(rune(0)) // Note: explicit null terminator.
34+
35+
s := obj.String() + string(rune(0))
3636
rv := []byte(s)
3737

3838
return &rv[0]
3939
}
4040

41-
func main() {}
41+
func main() {}

examples/filter_wasm_go/go.mod

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
module filter_wasm_go
22

3-
go 1.18
3+
go 1.22.5
44

5-
require (
6-
github.com/valyala/fastjson v1.6.3 // indirect
7-
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
8-
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
9-
)
5+
require github.com/valyala/fastjson v1.6.3

examples/filter_wasm_go/go.sum

-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,2 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2-
github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc=
3-
github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
4-
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
5-
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
6-
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
7-
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
8-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
10-
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
111
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
122
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
13-
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
14-
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
15-
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
16-
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
17-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
18-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)