Skip to content

Instantly share code, notes, and snippets.

View sunho's full-sized avatar
🐈
math is beutiful

Sunho Kim sunho

🐈
math is beutiful
View GitHub Profile
package main
import "fmt"
func main() {
var s []int
fmt.Println(s, len(s), cap(s))
if s == nil {
fmt.Println("nil!")
}
defer func() {
if r := recover(); r != nil {
t.reportErrorAndStop()
}
}()
var builtinActions = map[operationType]*action{
asdasdd
}
[]rune(input)
type ByteSlice []byte
func (p *ByteSlice) Write(data []byte) (n int, err error) {
slice := *p
// Again as above.
*p = slice
return len(data), nil
}
var b ByteSlice
fmt.Fprintf(&b, "This hour has %d days\n", 7)
type Sequence []int
// Methods required by sort.Interface.
func (s Sequence) Len() int {
return len(s)
}
func (s Sequence) Less(i, j int) bool {
return s[i] < s[j]
}
func (s Sequence) Swap(i, j int) {
type Sequence []int
// Method for printing - sorts the elements before printing
func (s Sequence) String() string {
sort.IntSlice(s).Sort()
return fmt.Sprint([]int(s))
}
str, ok := value.(string)
if ok {
fmt.Printf("string value is: %q\n", str)
} else {
fmt.Printf("value is not a string\n")
}
s := string(byteArray[:])
if item, ok := cmd.Commands[parms[0]]; ok {