Show HN: Simple wiki server written in Go
github.com
github.com
A friend and I implemented cookies, user login and database. However, I would recommend not using the SHA2 encryption method we used (we did it for fun not for security).
I wonder if "creat" is a valid function call somewhere.
The other examples you've provided mirror the Unix API; it would be more confusing to rename them, despite their unfortunate terseness.
As Someone1234 noted, this kind of inconsistency in a relatively new language is very puzzling.
That's one of the nice things about the .Net libraries, consistency within the naming and layout. Often times you could guess what something would be called and you would be correct.
Powershell took this one step further with their wonderful Verb-Noun pattern for everything: Get-Service, New-Service, Restart-Service, Start-Service, Stop-Service, and so on...
When I tried Go for the first time it was a marked improvement over for example C++, but the libraries are poorly laid out in my opinion, and the naming is hugely inconsistent. It is starting from a point of weakness, and I actually find classic C libraries a little better (C++ a lot worse), just because at least C is consistent with itself.
Seems like the Go designers thought saving characters was a more important design consideration than clarity. As if tab auto-completion wasn't a "thing."
In a world where millions of Chinese programmers have to use keywords written in a foreign language who am I to complain?
There is little reason to expect that reforming POSIX spelling is going to be any more successful than reforming English spelling.
http://gophercon.sourcegraph.com/post/83845316771/panel-disc...
I'm actually quite happy with how it turned out, I wanted something really simple to use but still have some nice features like showing the history of a page by leveraging Git.
Unfortunately I didn't get to use channels... Yet.
Coming from a Python background mostly I found Go pretty pleasing to work, however it took a while for me to grok the whole `$GOPATH` and dependencies stuff.
For anyone who might be interested in Go and is wondering how this is done, read the tutorial I mentioned. Go has solid documentation alongside a handful of tutorial style article that are worth reading.
[1] https://github.com/renstrom/go-wiki/commit/535c645fb25252e49...
var err error tail.Stdin, err = git.StdoutPipe() if err != nil { log.Println("ERROR", err) }
tail.Stdout = &out
err = tail.Start() if err != nil { log.Println("ERROR", err) }
err = git.Run() if err != nil { log.Println("ERROR", err) }
err = tail.Wait() if err != nil { log.Println("ERROR", err) }
Specifically, you've:
1. Encountered an error
2. Detected it
3. Printed it
But you've continued execution, and some of those errors are clearly not going to let you continue cleanly.
If you couldn't call git on the command line (i.e. it is not installed), then what are you going to do with the stdout? And if git was somehow replaced with something that only returned a status code and no output, then what are you going to do with no output?
The important point is that errors can be thrown because errors can plausibly exist in a way that affects you. You should handle them, logging is fine as a bare minimum but you probably also want to return and exit out of the func in a way that communicates to the thing that called the func that "Something went wrong, and I don't have the results you're looking for".
log.Println("ERROR", err)
return out.Bytes(), err
Or just: log.Println("ERROR", err)
return []byte, err
But I figured since the error will eventually get returned at the end anyway I moved on and kind of forgot about it. log.Printf("WARNING: something bad happened (nonfatal): %v\n", err)
or: log.Fatalf("FATAL ERROR: %v\n", err)
or maybe: // pass the buck
return err
That's it.