Skip to content

Commit 820d804

Browse files
authored
Merge pull request #88 from wrongerror/main
update go samples
2 parents 3e2f501 + 577d7ff commit 820d804

8 files changed

Lines changed: 22 additions & 19 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module main.go
22

3-
go 1.16
3+
go 1.17
44

55
require (
6-
github.com/OpenFunction/functions-framework-go v0.3.0
6+
github.com/OpenFunction/functions-framework-go v0.4.0
77
github.com/fatih/structs v1.1.0
88
k8s.io/klog/v2 v2.30.0
99
)

functions/knative/hello-world-go/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can refer to the [Installation Guide](https://github.com/OpenFunction/OpenFu
1111
Build the function locally
1212

1313
```sh
14-
pack build func-helloworld-go --builder openfunction/builder-go:v2.3.0-1.16 --env FUNC_NAME="HelloWorld" --env FUNC_CLEAR_SOURCE=true
14+
pack build func-helloworld-go --builder openfunction/builder-go:v2.4.0-1.17 --env FUNC_NAME="HelloWorld" --env FUNC_CLEAR_SOURCE=true
1515
```
1616

1717
Run the function
@@ -68,8 +68,8 @@ You can create this secret by editing the ``REGISTRY_SERVER``, ``REGISTRY_USER``
6868
```shell
6969
kubectl get functions.core.openfunction.io
7070
71-
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING ADDRESS AGE
72-
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.ofn.io/ 22m
71+
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING ADDRESS AGE
72+
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.svc.cluster.local/ 22m
7373
```
7474

7575
The `Function.status.addresses` field provides various methods for accessing functions.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module example.com/hello
22

3-
go 1.16
3+
go 1.17
44

5-
require github.com/OpenFunction/functions-framework-go v0.3.0
5+
require github.com/OpenFunction/functions-framework-go v0.4.0

functions/knative/hello-world-go/hello.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ package hello
22

33
import (
44
"fmt"
5+
ofctx "github.com/OpenFunction/functions-framework-go/context"
56
"net/http"
67

78
"github.com/OpenFunction/functions-framework-go/functions"
89
)
910

1011
func init() {
11-
functions.HTTP("HelloWorld", HelloWorld)
12+
functions.HTTP("HelloWorld", HelloWorld,
13+
functions.WithFunctionPath("/{greeting}"))
1214
}
1315

1416
func HelloWorld(w http.ResponseWriter, r *http.Request) {
15-
fmt.Fprintf(w, "Hello, %s!\n", r.URL.Path[1:])
17+
vars := ofctx.VarsFromCtx(r.Context())
18+
fmt.Fprintf(w, "Hello, %s!\n", vars["greeting"])
1619
}

functions/knative/multiple-functions-go/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can refer to the [Installation Guide](https://github.com/OpenFunction/OpenFu
1111
Build the function locally
1212

1313
```sh
14-
pack build multiple-functions-go --builder openfunction/builder-go:v2.3.0-1.16 --env FUNC_NAME="MultipleFunctions" --env FUNC_CLEAR_SOURCE=true
14+
pack build multiple-functions-go --builder openfunction/builder-go:v2.4.0-1.17 --env FUNC_NAME="MultipleFunctions" --env FUNC_CLEAR_SOURCE=true
1515
```
1616

1717
Run the function
@@ -72,8 +72,8 @@ You can create this secret by editing the ``REGISTRY_SERVER``, ``REGISTRY_USER``
7272
```shell
7373
kubectl get functions.core.openfunction.io
7474
75-
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE
76-
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.ofn.io/ 22m
75+
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING ADDRESS AGE
76+
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.svc.cluster.local/ 22m
7777
```
7878
The `Function.status.addresses` field provides various methods for accessing functions.
7979
Get `Function` addresses by running following command:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module example.com/hello
22

3-
go 1.16
3+
go 1.17
44

5-
require github.com/OpenFunction/functions-framework-go v0.3.0
5+
require github.com/OpenFunction/functions-framework-go v0.4.0

functions/knative/with-output-binding/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ Check the current function status:
132132
```shell
133133
kubectl get functions.core.openfunction.io
134134
135-
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE
136-
function-front Succeeded Running builder-bhbtk serving-vc6jw http://function-front.default.ofn.io/ 2m41s
137-
kafka-input Succeeded Running builder-dprfd serving-75vrt 2m21s
135+
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING ADDRESS AGE
136+
function-front Succeeded Running builder-bhbtk serving-vc6jw http://function-front.default.svc.cluster.local 2m41s
137+
kafka-input Succeeded Running builder-dprfd serving-75vrt 2m21s
138138
```
139139
140140
The `Function.status.addresses` field provides various methods for accessing functions.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module example.com/bindings
22

3-
go 1.16
3+
go 1.17
44

55
require (
6-
github.com/OpenFunction/functions-framework-go v0.2.2
6+
github.com/OpenFunction/functions-framework-go v0.4.0
77
github.com/fatih/structs v1.1.0
88
)

0 commit comments

Comments
 (0)