Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit c50c121

Browse files
Scaffolds basic wazero.io (#538)
Signed-off-by: Adrian Cole <[email protected]>
1 parent db465e5 commit c50c121

22 files changed

+217
-2
lines changed

.github/workflows/commit.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ name: Test
22
on:
33
pull_request:
44
branches: [main]
5+
paths-ignore: # ignore docs as they are built with Netlify.
6+
- '**/*.md'
7+
- 'site/**'
8+
- 'netlify.toml'
59
push:
610
branches: [main]
11+
paths-ignore: # ignore docs as they are built with Netlify.
12+
- '**/*.md'
13+
- 'site/**'
14+
- 'netlify.toml'
715

816
env: # Update this prior to requiring a higher minor version in go.mod
917
GO_VERSION: "1.17" # 1.xx == latest patch of 1.xx

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "site/themes/hello-friend"]
2+
path = site/themes/hello-friend
3+
url = https://github.com/panr/hugo-theme-hello-friend.git

.netlify/state.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"siteId": "070b842d-92a6-4bbf-bcc9-7cbfb635355e"
3+
}

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
goimports := golang.org/x/tools/cmd/[email protected]
22
golangci_lint := github.com/golangci/golangci-lint/cmd/[email protected]
3+
# sync this with netlify.toml!
4+
hugo := github.com/gohugoio/[email protected]
35

46
ensureJITFastest := -ldflags '-X github.com/tetratelabs/wazero/internal/integration_test/vs.ensureJITFastest=true'
57
.PHONY: bench
@@ -88,3 +90,8 @@ check:
8890
echo "The following differences will fail CI until committed:"; \
8991
git diff --exit-code; \
9092
fi
93+
94+
.PHONY: site
95+
site: ## Serve website content
96+
@git submodule update --init
97+
@cd site && go run $(hugo) server --minify --disableFastRender --baseURL localhost:1313 --cleanDestinationDir -D

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Import wazero and extend your Go application with code written in any language!
1212

1313
## Example
1414

15-
The best way to learn this and other features you get with wazero is by trying
16-
one of our [examples](examples).
15+
The best way to learn wazero is by trying one of our [examples](examples).
1716

1817
For the impatient, here's how invoking a factorial function looks in wazero:
1918

@@ -343,6 +342,9 @@ runtimes because [CGO is slow][27]. More specifically, if you make large amount
343342
of CGO calls which cross the boundary between Go and C (stack) space, then the
344343
usage of CGO could be a bottleneck.
345344

345+
-----
346+
wazero is a registered trademark of Tetrate.io, Inc. in the United States and/or other countries
347+
346348
[1]: https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/
347349
[2]: https://www.w3.org/TR/2022/WD-wasm-core-2-20220419/
348350
[3]: ./internal/integration_test/post1_0/multi-value/testdata/fac.wat

netlify.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build]
2+
base = "site"
3+
publish = "public"
4+
5+
[build.environment]
6+
HUGO_VERSION = "0.98.0"
7+
8+
[context.production]
9+
command = "git submodule update --init && hugo --gc --minify"
10+
11+
[context.deploy-preview]
12+
command = "git submodule update --init && hugo --gc --minify -b $DEPLOY_PRIME_URL"
13+
14+
[context.branch-deploy]
15+
command = "git submodule update --init && hugo --gc --minify -b $DEPLOY_PRIME_URL"

site/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resources/
2+
public/
3+
.DS_Store
4+
.hugo_build.lock

site/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# wazero.io
2+
3+
This directory holds the wazero site's source code. To visit the site, click [here](https://wazero.io/)
4+
5+
The website is built using [Hugo](https://gohugo.io/), as static website
6+
generator, and [Hello Friend](https://github.com/panr/hugo-theme-hello-friend) theme.
7+
8+
## Deployment process
9+
This site deploys via Netlify on change to the `main` branch.

site/config.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
baseURL = "https://wazero.io/"
2+
languageCode = "en-us"
3+
defaultContentLanguage = "en"
4+
title = "wazero"
5+
theme = "hello-friend"
6+
7+
[params]
8+
defaultTheme = "light"
9+
showReadingTime = false
10+
11+
[languages]
12+
[languages.en]
13+
# TODO: dark theme logo https://github.com/panr/hugo-theme-hello-friend/issues/291
14+
[languages.en.params.logo]
15+
logoText = "wazero"
16+
path = "/img/wazero.svg"
17+
[languages.en.menu]
18+
[[languages.en.menu.main]]
19+
url = "https://pkg.go.dev/github.com/tetratelabs/wazero"
20+
name = "API"
21+
weight = 10
22+
[[languages.en.menu.main]]
23+
url = "https://github.com/tetratelabs/wazero/blob/main/examples"
24+
name = "Examples"
25+
weight = 10
26+
[[languages.en.menu.main]]
27+
url = "https://github.com/tetratelabs/wazero"
28+
name = "GitHub"
29+
weight = 20

site/content/_index.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
+++
2+
title = "wazero: the zero dependency WebAssembly runtime for Go developers"
3+
layout = "single"
4+
+++
5+
6+
WebAssembly is a way to safely run code compiled in other languages. Runtimes
7+
execute WebAssembly Modules (Wasm), which are most often binaries with a
8+
`.wasm` extension.
9+
10+
wazero is the only zero dependency WebAssembly runtime written in Go.
11+
12+
## Example
13+
14+
The best way to learn wazero is by trying one of our [examples][1]
15+
16+
For the impatient, here's how invoking a factorial function looks in wazero:
17+
18+
```go
19+
func main() {
20+
// Choose the context to use for function calls.
21+
ctx := context.Background()
22+
23+
// Read a WebAssembly binary containing an exported "fac" function.
24+
// * Ex. (func (export "fac") (param i64) (result i64) ...
25+
source, err := os.ReadFile("./path/to/fac.wasm")
26+
if err != nil {
27+
log.Panicln(err)
28+
}
29+
30+
// Create a new WebAssembly Runtime.
31+
r := wazero.NewRuntime()
32+
defer r.Close(ctx) // This closes everything this Runtime created.
33+
34+
// Instantiate the module and return its exported functions
35+
module, err := r.InstantiateModuleFromCode(ctx, source)
36+
if err != nil {
37+
log.Panicln(err)
38+
}
39+
40+
// Discover 7! is 5040
41+
fmt.Println(module.ExportedFunction("fac").Call(ctx, 7))
42+
}
43+
```
44+
45+
Note: `fac.wasm` was compiled from [fac.wat][2], in the [WebAssembly 1.0][3]
46+
Text Format, it could have been written in another language that compiles to
47+
(targets) WebAssembly, such as AssemblyScript, C, C++, Rust, TinyGo or Zig.
48+
49+
## Why zero?
50+
51+
By avoiding CGO, wazero avoids prerequisites such as shared libraries or libc,
52+
and lets you keep features like cross compilation. Being pure Go, wazero adds
53+
only a small amount of size to your binary. Meanwhile, wazero’s API gives
54+
features you expect in Go, such as safe concurrency and context propagation.
55+
56+
### When can I use this?
57+
58+
wazero is an early project, so APIs are subject to change until version 1.0.
59+
To use wazero meanwhile, you need to add its main branch to your project like
60+
this:
61+
62+
```bash
63+
go get github.com/tetratelabs/wazero@main
64+
```
65+
66+
We expect [wazero 1.0][4] to be at or before Q3 2022, so please practice the
67+
current APIs to ensure they work for you, and give us a [star][5] if you are
68+
enjoying it so far!
69+
70+
[1]: https://github.com/tetratelabs/wazero/blob/main/examples
71+
[2]: https://github.com/tetratelabs/wazero/blob/main/internal/integration_test/post1_0/multi-value/testdata/fac.wat
72+
[3]: https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/
73+
[4]: https://github.com/tetratelabs/wazero/issues/506
74+
[5]: https://github.com/tetratelabs/wazero/stargazers
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- For Safari, 180 optimizes for iPhone Retina display -->
2+
<link rel="apple-touch-icon" sizes="180x180" href="/icons/[email protected]">
3+
<link rel="icon" type="image/png" sizes="32x32" href="/icons/[email protected]">
4+
<link rel="icon" type="image/png" sizes="16x16" href="/icons/[email protected]">
5+
<link rel="icon" href="/favicon.ico">
6+
<link rel="manifest" href="/manifest.webmanifest">

site/layouts/partials/footer.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<footer class="footer">
2+
<div class="footer__inner">
3+
<div class="copyright copyright--user">2022 © Tetrate.io, Inc.</div>
4+
</div>
5+
<div class="footer__inner">
6+
<div class="copyright copyright--user">wazero is a registered trademark of Tetrate.io, Inc. in the United States and/or other countries</div>
7+
</div>
8+
</footer>
9+
10+
<script src="{{ "assets/main.js" | absURL }}"></script>
11+
<script src="{{ "assets/prism.js" | absURL }}"></script>

site/static/.DS_Store

6 KB
Binary file not shown.

site/static/favicon.ico

15 KB
Binary file not shown.

site/static/img/[email protected]

387 Bytes
Loading

site/static/img/[email protected]

4.33 KB
Loading

site/static/img/[email protected]

4.67 KB
Loading

site/static/img/[email protected]

777 Bytes
Loading

site/static/img/[email protected]

13.7 KB
Loading

site/static/img/wazero.svg

Lines changed: 9 additions & 0 deletions
Loading

site/static/manifest.webmanifest

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "wazero",
3+
"short_name": "wazero",
4+
"description": "wazero: the zero dependency WebAssembly runtime for Go developers",
5+
"start_url": "/",
6+
"background_color": "white",
7+
"icons": [
8+
{
9+
"src": "img/[email protected]",
10+
"sizes": "16x16",
11+
"type": "image/png"
12+
},
13+
{
14+
"src": "img/[email protected]",
15+
"sizes": "32x32",
16+
"type": "image/png"
17+
},
18+
{
19+
"src": "img/[email protected]",
20+
"sizes": "180x180",
21+
"type": "image/png"
22+
},
23+
{
24+
"src": "img/[email protected]",
25+
"sizes": "192x192",
26+
"type": "image/png"
27+
},
28+
{
29+
"src": "img/[email protected]",
30+
"sizes": "512x512",
31+
"type": "image/png"
32+
}
33+
]
34+
}

site/themes/hello-friend

Submodule hello-friend added at 3ffa812

0 commit comments

Comments
 (0)