Client libarary for interfacing with the Nitric APIs as well as the creation of golang functions with Nitric.
- Get the Nitric CLI
- Create a new Nitric Project
nitric make:project <my-new-project>
- Select
function/golang15
as a starter function
import "github.com/nitrictech/go-sdk/api/events"
// NitricFunction - Handles individual function requests (http, events, etc.)
func createNitricClient() {
ec, err := events.New()
if err != nil {
// Do something with err
}
// use the new events client
// ec.Topic("my-topic").Publish(...)
}
package main
import "github.com/nitrictech/go-sdk/faas"
// NitricFunction - Handles individual function requests (http, events, etc.)
func NitricFunction(trigger *faas.NitricTrigger) (*faas.TriggerResponse, error) {
// Construct a default response base on the existing trigger context
resp := trigger.DefaultResponse()
resp.SetData([]byte("Hello Nitric"))
return resp, nil
}
func main() {
faas.Start(NitricFunction)
}