Minimal golang runtime. Functions are built as Go plugins, and the plugin is uploaded to fission. See `environments/go/README.md` for instructions and `examples/go` for a usage example. For now, we're re-using the 'code' field of the function to store the binary plugin. With v2 environments, this will be stored separately as a binary package.
31 lines
655 B
Markdown
31 lines
655 B
Markdown
# Go examples
|
|
|
|
The `go` runtime uses the [`plugin` package](https://golang.org/pkg/plugin/) to dynamically load an HTTP handler.
|
|
|
|
## Requirements
|
|
|
|
- go 1.8
|
|
- A [go-runtime fission environment](environments/go/README.md)
|
|
|
|
## Examples
|
|
|
|
### hello.go
|
|
|
|
`hello.go` is an very basic HTTP handler returning `"Hello, World!"`.
|
|
|
|
|
|
```
|
|
# Build the function as a plugin
|
|
$ ./build.sh
|
|
|
|
# Upload the function to fission
|
|
$ fission function create --name hello --env go-runtime --package hello.so
|
|
|
|
# Map /hello to the hello function
|
|
$ fission route create --method GET --url /hello --function hello
|
|
|
|
# Run the function
|
|
$ curl http://$FISSION_ROUTER/hello
|
|
Hello, World!
|
|
```
|