べすとえふぉーと

プログラミング等のノート 

2016-09-17から1日間の記事一覧

Go 使い方メモ インタフェース

go

package main import "fmt" type Calc interface { Calc(x int, y int) int } type Add struct { } func (r Add) Calc(x int, y int) int{ return x + y } type Sub struct { } func (r Sub) Calc(x int, y int) int{ return x - y } func main() { var add …

Go 使い方メモ 2

go

package main import ( "fmt" ) type myType int func for_range(array []int) { for i := range array { if i % 2 == 0 && array[i] % 2 == 0 { fmt.Println(array[i]) } } } func (value myType) printmethod() { fmt.Println(value) } func (value *myTyp…