The stack trace shows the panic to originate at wiki.go line 36. The code you provided only has 33 lines.
I ran the code you provided on macOS 10.12 and ubuntu 16.04 (both 64-bit) and its output was:
This is a sample Page.
I do not see anything obviously wrong with save or loadPage. My guess is that you are encountering some sort of file permissions problem. The errors from ioutil.WriteFile and ioutil.ReadFile will tell you about this, if you don’t ignore them.
My preferred way of dealing with errors when working with prototype or exploratory code is to run
log.SetFlags(log.Lshortfile)
as the first line of main to tell the log package (import "log") to print the filename and line number of any log messages. When errors are encountered, I use
if err != nil {
log.Fatalln(err)
}
as my default response to handling errors. This way I don’t have to think about error handling until I need to, and I get the benefits of not ignoring the errors.
The errors on lines 30 (p1.save) and 31 (p2, _ := loadPage("TestPage")) are not handled.
You should not need to run with superuser permissions. Since you are running ./wiki I assume you are running from your source directory, meaning your user should have the correct permissions. The tutorial will have the web server at port 8080, which can be opened by a regular user. A problem you could encounter is that files created by your wiki may be owned by root as you previously used superuser permissions. This can be fixed with chown or deleting the files (if they are not important).