Skip to content

Instantly share code, notes, and snippets.

@rdallman
Last active October 20, 2017 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdallman/e4539b6e443899e2bde9eb4ab9c57c2a to your computer and use it in GitHub Desktop.
Save rdallman/e4539b6e443899e2bde9eb4ab9c57c2a to your computer and use it in GitHub Desktop.
go-fdk-ex-1
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"os"
)
func main() {
var person struct {
Name string `json:"name"`
}
json.NewDecoder(os.Stdin).Decode(&person)
if person.Name == "" {
person.Name = "world"
}
msg := struct {
Msg string `json:"msg"`
}{
Msg: fmt.Sprintf("Hello %s!\n", person.Name),
}
json.NewEncoder(os.Stdout).Encode(&msg)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment