oinume journal

Scratchpad of what I learned


Handling uploaded files in Go

Handling uploaded files in Go is quite easy. Here is a complete example. net/http.Request.ParseMultipartForm parses a request body as multipart/form-data. You can get files with net/http.Request.FormFile after calling the method net/http.R…

go test in practice

This blog post describes basics and practical examples of go test. Go’s automated test mechanism is well designed and easy to use. I’ll show you some techniques of go test in this article. What is go test go test is a command to run automa…


これはGo Advent Calendar 2016の18日目の記事です。今回はGoでE2Eテストを行うためのライブラリagoutiについて書きます。 GoでE2Eテストを書く理由 WebアプリケーションのサーバーサイドをGoで書いている場合、GoでE2Eテストを書くメリットとして JavaScrip…

Arguments to defered functions are evaluated when the defer executes

The arguments to the deferred function (which include the receiver if the function is a method) are evaluated when the defer executes, not when the call executes. Effective Go - The Go Programming Language I sometimes make a mistake that d…

Go Tip: Don't take the address of loop variable

stackoverflow.com If you take the address of loop variable, it may cause a bug which all values are same. You might expect following program prints 5 10 15 but it prints 15 15 15. That’s because loop variable v is initialized just once. pa…

What I read, watched, listened recently

dotGo 2014 - Andrew Gerrand - 5 things I love Andrew Gerrand is a Googler and worked for Go. I watched this video just to learn English but it was good that he was describing Go's feature very well. www.youtube.com Golang UK Conference 201…

Detecting duplicated code in Golang with CPD and Jenkins

Use CPD to detect duplicated code in Golang. And visualize how much duplicated by Jenkins DRY plugin.

Mocking a HTTP access with http.Transport in Golang

Mocking HTTP access with http.RoundTripper






fswatchを使うと楽っぽい。 $ brew install fswatch $ fswatch . | xargs -n1 -I{} gofmt -w {} gofmt -w だと、stdoutに出力せずに直接対象ファイルに書き込まれる。


タイトルの通りだけど知らなかったので。明示的に空のsliceやmapを作らなくてもいいのは楽だ。 http://play.golang.org/p/veOWHGDdcn package main import "fmt" func emptyMap() map[string]string { return nil } func emptySlice() []string { return nil…



Revel Frameworkでのテスト

Revel Frameworkのテストについてまとめてみた。Revelは独自のユニットテストの仕組みを持っていて、サーバーを起動してそこに対してHTTPのクライアントでアクセスする仕組みになっている。



IntelliJ IDEAのgo-lang-idea-pluginをビルドする