- JSON is faster for small size data
- map (key size < 50 and Unmarshalling intensive workload)
- single struct
- gob is faster for big size data
- map (key size > 50 or Marshalling intensive workload)
- slice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ootahveali0weiChoo9eixir |
Goでよくやってしまうミスが3つあります。
私はそのミスを、分かりやすいように簡略した書き方ではなく、巷でよく見かける書き方のままここで説明します。
3つのミスの全てが、私の知る限り少なくとも1回づつ、Kubernetesの過去のコードレビューにありました。
1: ループ変数がループ外のスコープになっている
この各行はいったい何を行っているのでしょうか。想像してから下へスクロールしてください。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://cachethq.io/ | |
| upstream _cachet { | |
| # docker's ip and port | |
| server 127.0.0.1:8001; | |
| } | |
| server { | |
| listen 80; | |
| server_name cachet.example.com; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "io" | |
| "os" | |
| "testing" | |
| "github.com/stretchr/testify/assert" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "io" | |
| "os" | |
| "strings" | |
| "testing" | |
| "github.com/stretchr/testify/assert" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'ltsv' | |
| require 'json' | |
| result = {} | |
| STDIN.each do |line| | |
| record = LTSV.parse(line) | |
| path = false | |
| res = record[0] | |
| next if res.nil? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| func main() { | |
| p := []string{"Tokyo", "Kyoto", "Osaka", "Nagoya"} | |
| res := createPermurations(p) | |
| fmt.Printf("%v\n", res) | |
| } |