change main.go panics to error returns