Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 1.3 KB

3-3-GoHello.md

File metadata and controls

60 lines (43 loc) · 1.3 KB

Hello World - Go

Don't forget to replace <NNN> with your user number. Your lab instructor will give you your user number.

Reuse your first app

We will reuse the app you created in the Hello World - Node example. We will add the Go function to the same app.

Create a boiler plate Go function with an http trigger

fn init --runtime go --trigger http go-fn

Switch directory

cd go-fn

Deploy the function to the service

fn -v deploy --app ws<NNN>app --no-bump --no-cache

List functions

fn list functions ws<NNN>app

Invoke the function using CLI

fn -v invoke ws<NNN>app go-fn --display-call-id

Call ID: 01CWES47JM1BT0GGRZJ0000MN9
{"message":"Hello World"}

And you can pass parameters as shown below:

echo -n '{"name":"DOAG"}' | fn invoke ws<NNN>app go-fn --display-call-id --content-type application/json

Call ID: 01CWES1FR11BT0GGRZJ0000MKW
{"message":"Hello DOAG"}

Summary

Congratulations! You have successfully created, deployed and invoked your deployed Go function. Leave the app as-is for the next example in this workshop.