Skip to content

Commit a2477d6

Browse files
authored
Update wasmedge-go docs to 0.13.0. (#140)
Signed-off-by: YiYing He <yiying@secondstate.io>
1 parent ed358d5 commit a2477d6

File tree

5 files changed

+146
-174
lines changed

5 files changed

+146
-174
lines changed

docs/embed/go/reference/0.10.x.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
17091709

17101710
3. Table instance
17111711

1712-
In WasmEdge, developers can create the `Table` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Table` objects supply APIs to control the data in table instances.
1712+
In WasmEdge, developers can create the `Table` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Table` objects supply APIs to control the data in table instances.
17131713

17141714
```go
17151715
lim := wasmedge.NewLimitWithMax(10, 20)
@@ -1756,7 +1756,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
17561756

17571757
4. Memory instance
17581758

1759-
In WasmEdge, developers can create the `Memory` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Memory` objects supply APIs to control the data in memory instances.
1759+
In WasmEdge, developers can create the `Memory` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Memory` objects supply APIs to control the data in memory instances.
17601760

17611761
```go
17621762
lim := wasmedge.NewLimitWithMax(1, 5)
@@ -1796,7 +1796,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
17961796

17971797
5. Global instance
17981798

1799-
In WasmEdge, developers can create the `Global` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Global` objects supply APIs to control the value in global instances.
1799+
In WasmEdge, developers can create the `Global` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Global` objects supply APIs to control the value in global instances.
18001800

18011801
```go
18021802
// Create the global type with value type and mutation.
@@ -1827,7 +1827,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
18271827

18281828
### Host Functions
18291829

1830-
[Host functions](https://webassembly.github.io/spec/core/exec/runtime.html#syntax-hostfunc) are functions outside WebAssembly and passed to WASM modules as imports. In WasmEdge-go, developers can create the `Function`, `Memory`, `Table`, and `Global` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`.
1830+
[Host functions](https://webassembly.github.io/spec/core/exec/runtime.html#syntax-hostfunc) are functions outside WebAssembly and passed to WASM modules as imports. In WasmEdge, developers can create the `Function`, `Memory`, `Table`, and `Global` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`.
18311831

18321832
1. Host function allocation
18331833

@@ -2162,7 +2162,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
21622162
var data int32 = 0
21632163

21642164
// Create the module instance with the module name "extern".
2165-
impmod := wasmedge.NewImportObject("extern")
2165+
modinst := wasmedge.NewModule("extern")
21662166

21672167
// Create and add a function instance into the module instance with export name "func-add".
21682168
functype := wasmedge.NewFunctionType(
@@ -2171,10 +2171,10 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
21712171
)
21722172
hostfunc := wasmedge.NewFunction(functype, host_add, &data, 0)
21732173
functype.Release()
2174-
impmod.AddFunction("func-add", hostfunc)
2174+
modinst.AddFunction("func-add", hostfunc)
21752175

21762176
// Register the module instance into VM.
2177-
vm.RegisterImport(impmod)
2177+
vm.RegisterImport(modinst)
21782178

21792179
res, err := vm.RunWasmBuffer(wasmbuf, "addTwo", uint32(1234), uint32(5678))
21802180
if err == nil {
@@ -2184,7 +2184,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
21842184
}
21852185
fmt.Println("Data value:", data)
21862186

2187-
impmod.Release()
2187+
modinst.Release()
21882188
vm.Release()
21892189
}
21902190
```

docs/embed/go/reference/0.11.x.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
17351735

17361736
3. Table instance
17371737

1738-
In WasmEdge, developers can create the `Table` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Table` objects supply APIs to control the data in table instances.
1738+
In WasmEdge, developers can create the `Table` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Table` objects supply APIs to control the data in table instances.
17391739

17401740
```go
17411741
lim := wasmedge.NewLimitWithMax(10, 20)
@@ -1782,7 +1782,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
17821782

17831783
4. Memory instance
17841784

1785-
In WasmEdge, developers can create the `Memory` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Memory` objects supply APIs to control the data in memory instances.
1785+
In WasmEdge, developers can create the `Memory` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Memory` objects supply APIs to control the data in memory instances.
17861786

17871787
```go
17881788
lim := wasmedge.NewLimitWithMax(1, 5)
@@ -1822,7 +1822,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
18221822

18231823
5. Global instance
18241824

1825-
In WasmEdge, developers can create the `Global` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Global` objects supply APIs to control the value in global instances.
1825+
In WasmEdge, developers can create the `Global` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Global` objects supply APIs to control the value in global instances.
18261826

18271827
```go
18281828
// Create the global type with value type and mutation.
@@ -1853,7 +1853,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
18531853

18541854
### Host Functions
18551855

1856-
[Host functions](https://webassembly.github.io/spec/core/exec/runtime.html#syntax-hostfunc) are functions outside WebAssembly and passed to WASM modules as imports. In WasmEdge-go, developers can create the `Function`, `Memory`, `Table`, and `Global` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`.
1856+
[Host functions](https://webassembly.github.io/spec/core/exec/runtime.html#syntax-hostfunc) are functions outside WebAssembly and passed to WASM modules as imports. In WasmEdge, developers can create the `Function`, `Memory`, `Table`, and `Global` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`.
18571857

18581858
1. Host function allocation
18591859

@@ -2326,7 +2326,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
23262326
var data int32 = 0
23272327

23282328
// Create the module instance with the module name "extern".
2329-
impmod := wasmedge.NewImportObject("extern")
2329+
modinst := wasmedge.NewModule("extern")
23302330

23312331
// Create and add a function instance into the module instance with export name "func-add".
23322332
functype := wasmedge.NewFunctionType(
@@ -2335,10 +2335,10 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
23352335
)
23362336
hostfunc := wasmedge.NewFunction(functype, host_add, &data, 0)
23372337
functype.Release()
2338-
impmod.AddFunction("func-add", hostfunc)
2338+
modinst.AddFunction("func-add", hostfunc)
23392339

23402340
// Register the module instance into VM.
2341-
vm.RegisterImport(impmod)
2341+
vm.RegisterImport(modinst)
23422342

23432343
res, err := vm.RunWasmBuffer(wasmbuf, "addTwo", uint32(1234), uint32(5678))
23442344
if err == nil {
@@ -2348,7 +2348,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
23482348
}
23492349
fmt.Println("Data value:", data)
23502350

2351-
impmod.Release()
2351+
modinst.Release()
23522352
vm.Release()
23532353
}
23542354
```

docs/embed/go/reference/0.12.x.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ go version go1.16.5 linux/amd64
6262
Developers must [install the WasmEdge shared library](../../../start/install.md#install) with the same `WasmEdge-go` release or pre-release version.
6363

6464
```bash
65-
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.12.0
65+
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.12.1
6666
```
6767

6868
For the developers need the `TensorFlow` or `Image` extension for `WasmEdge-go`, please install the `WasmEdge` with extensions:
6969

7070
```bash
71-
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -e tf,image -v 0.12.0
71+
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -e tf,image -v 0.12.1
7272
```
7373

7474
Noticed that the `TensorFlow` and `Image` extensions are only for the `Linux` platforms. After installation, developers can use the `source` command to update the include and linking searching path.
@@ -78,7 +78,7 @@ Noticed that the `TensorFlow` and `Image` extensions are only for the `Linux` pl
7878
After the WasmEdge installation, developers can get the `WasmEdge-go` package and build it in your Go project directory.
7979

8080
```bash
81-
go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
81+
go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
8282
go build
8383
```
8484

@@ -760,7 +760,7 @@ The following shows the example of running the WASM for getting the Fibonacci. T
760760
Then you can build and run the Golang application with the WasmEdge Golang SDK: (the 21 Fibonacci number is 17711 in 0-based index)
761761

762762
```bash
763-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
763+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
764764
$ go build
765765
$ ./wasmedge_test
766766
Get fibonacci[21]: 17711
@@ -1069,7 +1069,7 @@ In WebAssembly, the instances in WASM modules can be exported and can be importe
10691069
Then you can build and run: (the 25th Fibonacci number is 121393 in 0-based index)
10701070

10711071
```bash
1072-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
1072+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
10731073
$ go build
10741074
$ ./wasmedge_test
10751075
Get fibonacci[25]: 121393
@@ -1119,7 +1119,7 @@ In WebAssembly, the instances in WASM modules can be exported and can be importe
11191119
Then you can build and run: (the 20th Fibonacci number is 10946 in 0-based index)
11201120

11211121
```bash
1122-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
1122+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
11231123
$ go build
11241124
$ ./wasmedge_test
11251125
Get the result: 10946
@@ -1186,7 +1186,7 @@ In WebAssembly, the instances in WASM modules can be exported and can be importe
11861186
Then you can build and run: (the 25th Fibonacci number is 121393 in 0-based index)
11871187

11881188
```bash
1189-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
1189+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
11901190
$ go build
11911191
$ ./wasmedge_test
11921192
Get the result: 121393
@@ -1284,7 +1284,7 @@ Sometimes the developers may have requirements to get the instances of the WASM
12841284
Then you can build and run: (the only exported function in `fibonacci.wasm` is `fib`)
12851285

12861286
```bash
1287-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
1287+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
12881288
$ go build
12891289
$ ./wasmedge_test
12901290
Exported function name: fib
@@ -1448,7 +1448,7 @@ func main() {
14481448
Then you can build and run: (the 18th Fibonacci number is 1346269 in 30-based index)
14491449

14501450
```bash
1451-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
1451+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
14521452
$ go build
14531453
$ ./wasmedge_test
14541454
Exported function name: fib
@@ -1726,7 +1726,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
17261726

17271727
3. Table instance
17281728

1729-
In WasmEdge, developers can create the `Table` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Table` objects supply APIs to control the data in table instances.
1729+
In WasmEdge, developers can create the `Table` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Table` objects supply APIs to control the data in table instances.
17301730

17311731
```go
17321732
lim := wasmedge.NewLimitWithMax(10, 20)
@@ -1773,7 +1773,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
17731773

17741774
4. Memory instance
17751775

1776-
In WasmEdge, developers can create the `Memory` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Memory` objects supply APIs to control the data in memory instances.
1776+
In WasmEdge, developers can create the `Memory` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Memory` objects supply APIs to control the data in memory instances.
17771777

17781778
```go
17791779
lim := wasmedge.NewLimitWithMax(1, 5)
@@ -1813,7 +1813,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
18131813

18141814
5. Global instance
18151815

1816-
In WasmEdge, developers can create the `Global` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`. The `Global` objects supply APIs to control the value in global instances.
1816+
In WasmEdge, developers can create the `Global` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`. The `Global` objects supply APIs to control the value in global instances.
18171817

18181818
```go
18191819
// Create the global type with value type and mutation.
@@ -1844,7 +1844,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
18441844

18451845
### Host Functions
18461846

1847-
[Host functions](https://webassembly.github.io/spec/core/exec/runtime.html#syntax-hostfunc) are functions outside WebAssembly and passed to WASM modules as imports. In WasmEdge-go, developers can create the `Function`, `Memory`, `Table`, and `Global` objects and add them into an `ImportObject` object for registering into a `VM` or a `Store`.
1847+
[Host functions](https://webassembly.github.io/spec/core/exec/runtime.html#syntax-hostfunc) are functions outside WebAssembly and passed to WASM modules as imports. In WasmEdge, developers can create the `Function`, `Memory`, `Table`, and `Global` objects and add them into an `wasmedge.Module` object for registering into a `VM` or a `Store`.
18481848

18491849
1. Host function allocation
18501850

@@ -2029,7 +2029,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
20292029
Then you can build and run the Golang application with the WasmEdge Golang SDK:
20302030

20312031
```bash
2032-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
2032+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
20332033
$ go build
20342034
$ ./wasmedge_test
20352035
[2022-08-26 15:06:40.384] [error] user defined failed: user defined error code, Code: 0x15be
@@ -2220,7 +2220,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
22202220
Then you can build and run the Golang application with the WasmEdge Golang SDK:
22212221

22222222
```bash
2223-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
2223+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
22242224
$ go build
22252225
$ ./wasmedge_test
22262226
Get the result: 6912
@@ -2293,7 +2293,7 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
22932293
var data int32 = 0
22942294

22952295
// Create the module instance with the module name "extern".
2296-
impmod := wasmedge.NewImportObject("extern")
2296+
modinst := wasmedge.NewModule("extern")
22972297

22982298
// Create and add a function instance into the module instance with export name "func-add".
22992299
functype := wasmedge.NewFunctionType(
@@ -2302,10 +2302,10 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
23022302
)
23032303
hostfunc := wasmedge.NewFunction(functype, host_add, &data, 0)
23042304
functype.Release()
2305-
impmod.AddFunction("func-add", hostfunc)
2305+
modinst.AddFunction("func-add", hostfunc)
23062306

23072307
// Register the module instance into VM.
2308-
vm.RegisterImport(impmod)
2308+
vm.RegisterImport(modinst)
23092309

23102310
res, err := vm.RunWasmBuffer(wasmbuf, "addTwo", uint32(1234), uint32(5678))
23112311
if err == nil {
@@ -2315,15 +2315,15 @@ The instances are the runtime structures of WASM. Developers can retrieve the `M
23152315
}
23162316
fmt.Println("Data value:", data)
23172317

2318-
impmod.Release()
2318+
modinst.Release()
23192319
vm.Release()
23202320
}
23212321
```
23222322

23232323
Then you can build and run the Golang application with the WasmEdge Golang SDK:
23242324

23252325
```bash
2326-
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.0
2326+
$ go get github.com/second-state/WasmEdge-go/wasmedge@v0.12.1
23272327
$ go build
23282328
$ ./wasmedge_test
23292329
Get the result: 6912

0 commit comments

Comments
 (0)