Last active
October 20, 2017 23:22
-
-
Save rdallman/e4539b6e443899e2bde9eb4ab9c57c2a to your computer and use it in GitHub Desktop.
go-fdk-ex-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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