Scaffolds basic wazero.io (#538)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
8
.github/workflows/commit.yaml
vendored
@@ -2,8 +2,16 @@ name: Test
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths-ignore: # ignore docs as they are built with Netlify.
|
||||
- '**/*.md'
|
||||
- 'site/**'
|
||||
- 'netlify.toml'
|
||||
push:
|
||||
branches: [main]
|
||||
paths-ignore: # ignore docs as they are built with Netlify.
|
||||
- '**/*.md'
|
||||
- 'site/**'
|
||||
- 'netlify.toml'
|
||||
|
||||
env: # Update this prior to requiring a higher minor version in go.mod
|
||||
GO_VERSION: "1.17" # 1.xx == latest patch of 1.xx
|
||||
|
||||
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "site/themes/hello-friend"]
|
||||
path = site/themes/hello-friend
|
||||
url = https://github.com/panr/hugo-theme-hello-friend.git
|
||||
3
.netlify/state.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"siteId": "070b842d-92a6-4bbf-bcc9-7cbfb635355e"
|
||||
}
|
||||
7
Makefile
@@ -1,5 +1,7 @@
|
||||
goimports := golang.org/x/tools/cmd/goimports@v0.1.10
|
||||
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.0
|
||||
# sync this with netlify.toml!
|
||||
hugo := github.com/gohugoio/hugo@v0.98.0
|
||||
|
||||
ensureJITFastest := -ldflags '-X github.com/tetratelabs/wazero/internal/integration_test/vs.ensureJITFastest=true'
|
||||
.PHONY: bench
|
||||
@@ -88,3 +90,8 @@ check:
|
||||
echo "The following differences will fail CI until committed:"; \
|
||||
git diff --exit-code; \
|
||||
fi
|
||||
|
||||
.PHONY: site
|
||||
site: ## Serve website content
|
||||
@git submodule update --init
|
||||
@cd site && go run $(hugo) server --minify --disableFastRender --baseURL localhost:1313 --cleanDestinationDir -D
|
||||
|
||||
@@ -12,8 +12,7 @@ Import wazero and extend your Go application with code written in any language!
|
||||
|
||||
## Example
|
||||
|
||||
The best way to learn this and other features you get with wazero is by trying
|
||||
one of our [examples](examples).
|
||||
The best way to learn wazero is by trying one of our [examples](examples).
|
||||
|
||||
For the impatient, here's how invoking a factorial function looks in wazero:
|
||||
|
||||
@@ -343,6 +342,9 @@ runtimes because [CGO is slow][27]. More specifically, if you make large amount
|
||||
of CGO calls which cross the boundary between Go and C (stack) space, then the
|
||||
usage of CGO could be a bottleneck.
|
||||
|
||||
-----
|
||||
wazero is a registered trademark of Tetrate.io, Inc. in the United States and/or other countries
|
||||
|
||||
[1]: https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/
|
||||
[2]: https://www.w3.org/TR/2022/WD-wasm-core-2-20220419/
|
||||
[3]: ./internal/integration_test/post1_0/multi-value/testdata/fac.wat
|
||||
|
||||
15
netlify.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[build]
|
||||
base = "site"
|
||||
publish = "public"
|
||||
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.98.0"
|
||||
|
||||
[context.production]
|
||||
command = "git submodule update --init && hugo --gc --minify"
|
||||
|
||||
[context.deploy-preview]
|
||||
command = "git submodule update --init && hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
||||
|
||||
[context.branch-deploy]
|
||||
command = "git submodule update --init && hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
||||
4
site/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
resources/
|
||||
public/
|
||||
.DS_Store
|
||||
.hugo_build.lock
|
||||
9
site/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# wazero.io
|
||||
|
||||
This directory holds the wazero site's source code. To visit the site, click [here](https://wazero.io/)
|
||||
|
||||
The website is built using [Hugo](https://gohugo.io/), as static website
|
||||
generator, and [Hello Friend](https://github.com/panr/hugo-theme-hello-friend) theme.
|
||||
|
||||
## Deployment process
|
||||
This site deploys via Netlify on change to the `main` branch.
|
||||
29
site/config.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
baseURL = "https://wazero.io/"
|
||||
languageCode = "en-us"
|
||||
defaultContentLanguage = "en"
|
||||
title = "wazero"
|
||||
theme = "hello-friend"
|
||||
|
||||
[params]
|
||||
defaultTheme = "light"
|
||||
showReadingTime = false
|
||||
|
||||
[languages]
|
||||
[languages.en]
|
||||
# TODO: dark theme logo https://github.com/panr/hugo-theme-hello-friend/issues/291
|
||||
[languages.en.params.logo]
|
||||
logoText = "wazero"
|
||||
path = "/img/wazero.svg"
|
||||
[languages.en.menu]
|
||||
[[languages.en.menu.main]]
|
||||
url = "https://pkg.go.dev/github.com/tetratelabs/wazero"
|
||||
name = "API"
|
||||
weight = 10
|
||||
[[languages.en.menu.main]]
|
||||
url = "https://github.com/tetratelabs/wazero/blob/main/examples"
|
||||
name = "Examples"
|
||||
weight = 10
|
||||
[[languages.en.menu.main]]
|
||||
url = "https://github.com/tetratelabs/wazero"
|
||||
name = "GitHub"
|
||||
weight = 20
|
||||
74
site/content/_index.md
Normal file
@@ -0,0 +1,74 @@
|
||||
+++
|
||||
title = "wazero: the zero dependency WebAssembly runtime for Go developers"
|
||||
layout = "single"
|
||||
+++
|
||||
|
||||
WebAssembly is a way to safely run code compiled in other languages. Runtimes
|
||||
execute WebAssembly Modules (Wasm), which are most often binaries with a
|
||||
`.wasm` extension.
|
||||
|
||||
wazero is the only zero dependency WebAssembly runtime written in Go.
|
||||
|
||||
## Example
|
||||
|
||||
The best way to learn wazero is by trying one of our [examples][1]
|
||||
|
||||
For the impatient, here's how invoking a factorial function looks in wazero:
|
||||
|
||||
```go
|
||||
func main() {
|
||||
// Choose the context to use for function calls.
|
||||
ctx := context.Background()
|
||||
|
||||
// Read a WebAssembly binary containing an exported "fac" function.
|
||||
// * Ex. (func (export "fac") (param i64) (result i64) ...
|
||||
source, err := os.ReadFile("./path/to/fac.wasm")
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
// Create a new WebAssembly Runtime.
|
||||
r := wazero.NewRuntime()
|
||||
defer r.Close(ctx) // This closes everything this Runtime created.
|
||||
|
||||
// Instantiate the module and return its exported functions
|
||||
module, err := r.InstantiateModuleFromCode(ctx, source)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
// Discover 7! is 5040
|
||||
fmt.Println(module.ExportedFunction("fac").Call(ctx, 7))
|
||||
}
|
||||
```
|
||||
|
||||
Note: `fac.wasm` was compiled from [fac.wat][2], in the [WebAssembly 1.0][3]
|
||||
Text Format, it could have been written in another language that compiles to
|
||||
(targets) WebAssembly, such as AssemblyScript, C, C++, Rust, TinyGo or Zig.
|
||||
|
||||
## Why zero?
|
||||
|
||||
By avoiding CGO, wazero avoids prerequisites such as shared libraries or libc,
|
||||
and lets you keep features like cross compilation. Being pure Go, wazero adds
|
||||
only a small amount of size to your binary. Meanwhile, wazero’s API gives
|
||||
features you expect in Go, such as safe concurrency and context propagation.
|
||||
|
||||
### When can I use this?
|
||||
|
||||
wazero is an early project, so APIs are subject to change until version 1.0.
|
||||
To use wazero meanwhile, you need to add its main branch to your project like
|
||||
this:
|
||||
|
||||
```bash
|
||||
go get github.com/tetratelabs/wazero@main
|
||||
```
|
||||
|
||||
We expect [wazero 1.0][4] to be at or before Q3 2022, so please practice the
|
||||
current APIs to ensure they work for you, and give us a [star][5] if you are
|
||||
enjoying it so far!
|
||||
|
||||
[1]: https://github.com/tetratelabs/wazero/blob/main/examples
|
||||
[2]: https://github.com/tetratelabs/wazero/blob/main/internal/integration_test/post1_0/multi-value/testdata/fac.wat
|
||||
[3]: https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/
|
||||
[4]: https://github.com/tetratelabs/wazero/issues/506
|
||||
[5]: https://github.com/tetratelabs/wazero/stargazers
|
||||
6
site/layouts/partials/extended_head.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<!-- For Safari, 180 optimizes for iPhone Retina display -->
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/icons/icon@180w.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/icons/icon@32w.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/icons/icon@16w.png">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<link rel="manifest" href="/manifest.webmanifest">
|
||||
11
site/layouts/partials/footer.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<footer class="footer">
|
||||
<div class="footer__inner">
|
||||
<div class="copyright copyright--user">2022 © Tetrate.io, Inc.</div>
|
||||
</div>
|
||||
<div class="footer__inner">
|
||||
<div class="copyright copyright--user">wazero is a registered trademark of Tetrate.io, Inc. in the United States and/or other countries</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="{{ "assets/main.js" | absURL }}"></script>
|
||||
<script src="{{ "assets/prism.js" | absURL }}"></script>
|
||||
BIN
site/static/.DS_Store
vendored
Normal file
BIN
site/static/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
site/static/img/icon@16w.png
Normal file
|
After Width: | Height: | Size: 387 B |
BIN
site/static/img/icon@180w.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
site/static/img/icon@192w.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
site/static/img/icon@32w.png
Normal file
|
After Width: | Height: | Size: 777 B |
BIN
site/static/img/icon@512w.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
9
site/static/img/wazero.svg
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
34
site/static/manifest.webmanifest
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "wazero",
|
||||
"short_name": "wazero",
|
||||
"description": "wazero: the zero dependency WebAssembly runtime for Go developers",
|
||||
"start_url": "/",
|
||||
"background_color": "white",
|
||||
"icons": [
|
||||
{
|
||||
"src": "img/icon@16w.png",
|
||||
"sizes": "16x16",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "img/icon@32w.png",
|
||||
"sizes": "32x32",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "img/icon@180w.png",
|
||||
"sizes": "180x180",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "img/icon@192w.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "img/icon@512w.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||