Comment

Comment by dewey

As this seems to be a beginner project to learn here's some thoughts on the code:

1) You should really not build your json by manually building the string. That's very error prone and hard to extend.

  fmt.Fprintf(f,
  "{\n\t\"from\": {\n\t\t\"name\": \"%s\",

Use https://golang.org/pkg/encoding/json/ (https://gobyexample.com/json) instead. Working with json in Go is really one of the nicer features of Go (It's Go, not "GoLang")

2) By setting / typoing a config option you could accidentally delete files from your computer, even your home directory

  err := os.Remove(jsonfile)
parent dewey 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton