rewriting server code in go