Standard Library Hits
High-frequency standard library packages. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Search across all documentation pages
High-frequency standard library packages. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Efficient string building.
var b strings.Builder
b.WriteString("a")
b.WriteString("b")
b.String() // "ab"Parse and format numbers.
n, err := strconv.Atoi("42")
n // 42
// err == nil
strconv.Itoa(7) // "7"Reference layout Mon Jan 2 15:04:05 MST 2006.
t := time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC)
t.Format(time.RFC3339) // "2020-01-02T00:00:00Z"Marshal and unmarshal.
b, _ := json.Marshal(struct{ A int }{A: 1})
string(b) // {"A":1}Stream copy between reader and writer.
// n, err := io.Copy(dst, src)In-memory buffer.
var buf bytes.Buffer
buf.WriteString("x")
buf.String() // "x"Formatting without print.
fmt.Sprintf("%s-%d", "a", 1) // "a-1"Sort helpers.
s := []int{3, 1, 2}
sort.Ints(s)
s // [1 2 3]Compile once when possible.
re := regexp.MustCompile("^\\d+$")
re.MatchString("42") // trueRead whole small files.
// b, err := os.ReadFile("f.txt")Join paths portably.
filepath.Join("a", "b") // a/b (OS sep)Structured logging (Go 1.21+).
// slog.Info("hello", "user", "ada")slices package helpers (Go 1.21+).
// slices.Contains([]int{1, 2}, 2) == trueOrdered compares (Go 1.21+).
// cmp.Compare(1, 2) == -1sync.Map for special cases - prefer Mutex map usually.
// var m sync.MapStack versions: Go 1.26.x · chi/gin/echo latest (verify at build)
Reviewed by Chris St. John·Last updated Jul 18, 2026