From 3bc775b30932ef2a43e3c6139fbe8fc5091f888c Mon Sep 17 00:00:00 2001 From: "luoni.fz" Date: Thu, 3 Nov 2022 23:20:01 +0800 Subject: [PATCH] update golang demo --- event-function/fc-event-golang1.x/publish.yaml | 2 +- event-function/fc-event-golang1.x/src/code/go.mod | 2 +- event-function/fc-event-golang1.x/src/code/main.go | 12 ++---------- event-function/fc-event-golang1.x/src/s.yaml | 2 +- event-function/fc-event-golang1.x/src/s_en.yaml | 2 +- http-function/fc-http-golang1.x/publish.yaml | 2 +- http-function/fc-http-golang1.x/src/code/go.mod | 2 +- http-function/fc-http-golang1.x/src/s.yaml | 2 +- http-function/fc-http-golang1.x/src/s_en.yaml | 2 +- update.list | 3 ++- 10 files changed, 12 insertions(+), 19 deletions(-) diff --git a/event-function/fc-event-golang1.x/publish.yaml b/event-function/fc-event-golang1.x/publish.yaml index a469f87..da09b0c 100644 --- a/event-function/fc-event-golang1.x/publish.yaml +++ b/event-function/fc-event-golang1.x/publish.yaml @@ -1,6 +1,6 @@ Type: Application Name: start-fc-event-golang1.x -Version: 0.0.15 +Version: 0.0.16 Provider: - 阿里云 Description: 快速部署一个 golang1.x 的 Event 类型的 Hello World 函数到阿里云函数计算。 diff --git a/event-function/fc-event-golang1.x/src/code/go.mod b/event-function/fc-event-golang1.x/src/code/go.mod index 3a466d8..e47f88c 100644 --- a/event-function/fc-event-golang1.x/src/code/go.mod +++ b/event-function/fc-event-golang1.x/src/code/go.mod @@ -1,3 +1,3 @@ module main -require github.com/aliyun/fc-runtime-go-sdk v0.0.3 // indirect +require github.com/aliyun/fc-runtime-go-sdk v0.2.7 diff --git a/event-function/fc-event-golang1.x/src/code/main.go b/event-function/fc-event-golang1.x/src/code/main.go index a5ba9b4..0b6e032 100644 --- a/event-function/fc-event-golang1.x/src/code/main.go +++ b/event-function/fc-event-golang1.x/src/code/main.go @@ -10,16 +10,8 @@ func main() { fc.Start(HandleRequest) } -/* -event: -{ - "key1": "value1", - "key2": "value2", - "key3": "value3" -} -*/ -func HandleRequest(event map[string]interface{}) (string, error) { - fmt.Printf("event: %v\n", event) +func HandleRequest(event []byte) (string, error) { + fmt.Printf("event: %s\n", string(event)) fmt.Println("hello world! 你好,世界!") return "hello world! 你好,世界!", nil } diff --git a/event-function/fc-event-golang1.x/src/s.yaml b/event-function/fc-event-golang1.x/src/s.yaml index 45473b8..66cb9a4 100644 --- a/event-function/fc-event-golang1.x/src/s.yaml +++ b/event-function/fc-event-golang1.x/src/s.yaml @@ -37,7 +37,7 @@ services: pre-deploy: # 在deploy之前运行 - run: GO111MODULE=on go get github.com/aliyun/fc-runtime-go-sdk path: ./code - - run: GOOS=linux CGO_ENABLED=0 go build -o target/main main.go + - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go path: ./code # - component: fc build --use-docker --dockerfile ./code/Dockerfile # 要运行的组件,格式为【component: 组件名 命令 参数】(可以通过s cli registry search --type Component 获取组件列表) # - run: docker build xxx # 要执行的系统命令,类似于一种钩子的形式 diff --git a/event-function/fc-event-golang1.x/src/s_en.yaml b/event-function/fc-event-golang1.x/src/s_en.yaml index ef42a0e..2523f20 100644 --- a/event-function/fc-event-golang1.x/src/s_en.yaml +++ b/event-function/fc-event-golang1.x/src/s_en.yaml @@ -37,7 +37,7 @@ services: pre-deploy: # run before deploy - run: GO111MODULE=on go get github.com/aliyun/fc-runtime-go-sdk path: ./code - - run: GOOS=linux CGO_ENABLED=0 go build -o target/main main.go + - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go path: ./code # - component: fc build --use-docker --dockerfile ./code/Dockerfile # The component to run, the format is [component: component name command parameter] (you can get the component list through s cli registry search --type Component) # - run: docker build xxx # System command to execute, similar to a hook diff --git a/http-function/fc-http-golang1.x/publish.yaml b/http-function/fc-http-golang1.x/publish.yaml index 9036e6b..02cd147 100644 --- a/http-function/fc-http-golang1.x/publish.yaml +++ b/http-function/fc-http-golang1.x/publish.yaml @@ -1,6 +1,6 @@ Type: Application Name: start-fc-http-golang1.x -Version: 0.0.15 +Version: 0.0.16 Provider: - 阿里云 Description: 快速部署一个 golang1.x 的 HTTP 类型的 Hello World 函数到阿里云函数计算。 diff --git a/http-function/fc-http-golang1.x/src/code/go.mod b/http-function/fc-http-golang1.x/src/code/go.mod index 3a466d8..e47f88c 100644 --- a/http-function/fc-http-golang1.x/src/code/go.mod +++ b/http-function/fc-http-golang1.x/src/code/go.mod @@ -1,3 +1,3 @@ module main -require github.com/aliyun/fc-runtime-go-sdk v0.0.3 // indirect +require github.com/aliyun/fc-runtime-go-sdk v0.2.7 diff --git a/http-function/fc-http-golang1.x/src/s.yaml b/http-function/fc-http-golang1.x/src/s.yaml index deb671b..1317388 100644 --- a/http-function/fc-http-golang1.x/src/s.yaml +++ b/http-function/fc-http-golang1.x/src/s.yaml @@ -37,7 +37,7 @@ services: pre-deploy: # 在deploy之前运行 - run: GO111MODULE=on go get github.com/aliyun/fc-runtime-go-sdk path: ./code - - run: GO111MODULE=on GOOS=linux CGO_ENABLED=0 go build -o target/main main.go + - run: GO111MODULE=on GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go path: ./code # - component: fc build --use-docker --dockerfile ./code/Dockerfile # 要运行的组件,格式为【component: 组件名 命令 参数】(可以通过s cli registry search --type Component 获取组件列表) # - run: docker build xxx # 要执行的系统命令,类似于一种钩子的形式 diff --git a/http-function/fc-http-golang1.x/src/s_en.yaml b/http-function/fc-http-golang1.x/src/s_en.yaml index 416a638..5596bd4 100644 --- a/http-function/fc-http-golang1.x/src/s_en.yaml +++ b/http-function/fc-http-golang1.x/src/s_en.yaml @@ -37,7 +37,7 @@ services: pre-deploy: # run before deploy - run: GO111MODULE=on go get github.com/aliyun/fc-runtime-go-sdk path: ./code - - run: GO111MODULE=on GOOS=linux CGO_ENABLED=0 go build -o target/main main.go + - run: GO111MODULE=on GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go path: ./code # - component: fc build --use-docker --dockerfile ./code/Dockerfile # The component to run, the format is [component: component name command parameter] (you can get the component list through s cli registry search --type Component) # - run: docker build xxx # System command to execute, similar to a hook diff --git a/update.list b/update.list index 1a48bf9..1814aa3 100644 --- a/update.list +++ b/update.list @@ -1 +1,2 @@ -custom-container-function/fc-custom-container-http-springboot +event-function/fc-event-golang1.x +http-function/fc-http-golang1.x