Enable go module support for go environment (#1152)

This commit is contained in:
Ta-Ching Chen
2019-07-10 14:00:29 +08:00
committed by GitHub
parent 9e7dd5aa27
commit 58722f849a
46 changed files with 130 additions and 6538 deletions
+35
View File
@@ -0,0 +1,35 @@
# Go module usage
1. Initialize your project
```bash
$ go mod init "<module>"
```
For example,
```bash
$ go mod init "github.com/fission/fission/examples/go/go-module-example"
```
2. Add dependencies
* See [here](https://github.com/golang/go/wiki/Modules#daily-workflow)
3. Verify
```bash
$ go mod verify
```
4. Archive and create package as usual
```bash
$ zip -r go.zip .
adding: go.mod (deflated 26%)
adding: go.sum (deflated 1%)
adding: README.md (deflated 37%)
adding: main.go (deflated 30%)
$ fission pkg create --env go --src go.zip
```
+3
View File
@@ -0,0 +1,3 @@
module github.com/fission/fission/examples/go/go-module-example
require github.com/golang/example v0.0.0-20170904185048-46695d81d1fa
+1
View File
@@ -0,0 +1 @@
github.com/golang/example v0.0.0-20170904185048-46695d81d1fa/go.mod h1:tO/5UvQ/uKigUjQBPqzstj6uxd3fUIjddi19DxGJeWg=
+13
View File
@@ -0,0 +1,13 @@
package main
import (
"net/http"
"github.com/golang/example/stringutil"
)
// Handler is the entry point for this fission function
func Handler(w http.ResponseWriter, r *http.Request) {
msg := stringutil.Reverse(stringutil.Reverse("Vendor Example Test"))
w.Write([]byte(msg))
}