Go语言中文网 为您找到相关结果 2

用golang打印数字

效果: guodeMacBook-Air:programming_in_go guo$ go run 1_1.go 1234 1 222222 333333 4 4 1 1 2 3 4 4 1 222222 333333 444444 1 2 3 4 1111111 222222 333333 4 go 源码(节选) package main import ( "fmt" "os" ) func main() { if len(os.Args) != 2 { fmt.Printf("%s number\n", os.Args[0]) return } bigdigits := [][]string{ {" 000 ", " 0 0", " 0 0", " 0 0", " 000 ", }, ...阅读全文

博文 2015-04-29 23:00:00 guonaihong

书籍:The Way To Go,第二部分

Interface type Shaper interface { Area() float32 } type Square struct { side float32 } func (sq *Square) Area() float32 { return sq.side * sq.side } func main() { sq1 := new(Square) sq1.side = 5 areaIntf := Shaper(sq1) // areaIntf := sq1 fmt.Printf(“%f\n”, areaIntf.Area()) } r := Rectangle{5, 3} q := &square{5} shapes := []Shaper{r, q} for n, _ := ...阅读全文

博文 2014-10-13 16:00:01 月光独奏