main.go 704 B

1234567891011121314151617181920212223242526272829
  1. // Solution to part 1 of the Whispering Gophers code lab.
  2. // This program reads from standard input and writes JSON-encoded messages to
  3. // standard output. For example, this input line:
  4. // Hello!
  5. // Produces this output:
  6. // {"Body":"Hello!"}
  7. //
  8. package main
  9. import (
  10. "bufio"
  11. "encoding/json"
  12. "log"
  13. "os"
  14. )
  15. type Message struct {
  16. Body string
  17. }
  18. func main() {
  19. // TODO: Create a new bufio.Scanner reading from the standard input.
  20. // TODO: Create a new json.Encoder writing into the standard output.
  21. for /* TODO: Iterate over every line in the scanner */ {
  22. // TODO: Create a new message with the read text.
  23. // TODO: Encode the message, and check for errors!
  24. }
  25. // TODO: Check for a scan error.
  26. }