サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
災害への備え
yourbasic.org
Remove all elements Keep allocated memory Empty slice vs. nil slice Remove all elements To remove all elements, simply set the slice to nil. a := []string{"A", "B", "C", "D", "E"} a = nil fmt.Println(a, len(a), cap(a)) // [] 0 0 This will release the underlying array to the garbage collector (assuming there are no other references). Keep allocated memory To keep the underlying array, slice the sli
Declarations generally take the form of a keyword followed by the name of the object being declared. The keyword is one of const, type, var, or func. You can also use a keyword followed by a series of declarations in parentheses. var ( n int x float64 ) When declaring a function, you must either provide a name for each parameter or not provide a name for any parameter; you can’t omit some names an
* In `` string literals, text is interpreted literally and backslashes have no special meaning. See Escapes and multiline strings for more on raw strings, escape characters and string encodings. Concatenate Expression Result Note
The Petersen graph and its complement Introduction This text is about the implementation of a Go tool based entirely on functions – the API contains only immutable data types, and the code is built on top of a struct with five func fields. It’s a tool for building virtual graphs. In a virtual graph no vertices or edges are stored in memory, they are instead computed as needed. The tool is part of
Clean and simple string building (fmt) High-performance string concatenation (stringbuilder) Before Go 1.10 (bytebuffer) Clean and simple string building For simple cases where performance is a non-issue, fmt.Sprintf is your friend. It’s clean, simple and fairly efficient. s := fmt.Sprintf("Size: %d MB.", 85) // s == "Size: 85 MB." The fmt cheat sheet lists the most common formatting verbs and fla
このページを最初にブックマークしてみませんか?
『Algorithms to Go』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く