Slide 1

Slide 1 text

GolangͰ৺Λແʹͯ͠ίʔυΛॻ͘ mitsuse@github LINE Developer Meetup #11

Slide 2

Slide 2 text

͓·͑ɺͩΕΑɻ

Slide 3

Slide 3 text

͓·͑ɺͩΕΑɻ

Slide 4

Slide 4 text

͓·͑ɺͩΕΑɻ ɾಸྑͰࣗવݴޠॲཧ΍ͬͯͨ

Slide 5

Slide 5 text

͓·͑ɺͩΕΑɻ ɾಸྑͰࣗવݴޠॲཧ΍ͬͯͨ ɾݩPythonistaͰGopherͰVimmer

Slide 6

Slide 6 text

͓·͑ɺͩΕΑɻ ɾಸྑͰࣗવݴޠॲཧ΍ͬͯͨ ɾ࢓ࣄͰ͸Scalaॻ͍ͯΔɾAkkaྑ͍ ɾݩPythonistaͰGopherͰVimmer

Slide 7

Slide 7 text

͓·͑ɺͩΕΑɻ ɾಸྑͰࣗવݴޠॲཧ΍ͬͯͨ ɾGoCon 2015ࢀՃࣦഊ͠·ͨ͠ ɾݩPythonistaͰGopherͰVimmer ɾ࢓ࣄͰ͸Scalaॻ͍ͯΔɾAkkaྑ͍

Slide 8

Slide 8 text

Golangॻ͍ͯ·͔͢ʁ

Slide 9

Slide 9 text

Golangͱ͸ Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. The Go Programming Language https://golang.org/

Slide 10

Slide 10 text

Golangͱ͸ Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. The Go Programming Language https://golang.org/

Slide 11

Slide 11 text

Golangͱ͸ Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. The Go Programming Language https://golang.org/

Slide 12

Slide 12 text

Golangͱ͸ Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. The Go Programming Language https://golang.org/

Slide 13

Slide 13 text

Golangͱ͸ Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. The Go Programming Language https://golang.org/

Slide 14

Slide 14 text

Golangͱ͸ Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. The Go Programming Language https://golang.org/ γϯϓϧͰ৴པੑͷ͋Δޮ཰ͷྑ͍ιϑτ΢ΣΞͷߏஙΛָʹʂ

Slide 15

Slide 15 text

ͳͥॻ͘ͷ͔ɿ ৺Λແʹͯ͠ॻ͘ͷʹௐ౓ྑ͍͔Β

Slide 16

Slide 16 text

ͳͥॻ͘ͷ͔ɿ ৺Λແʹͯ͠ॻ͘ͷʹௐ౓ྑ͍͔Β ॆ࣮ͨ͠πʔϧ܈ʹΑΔαϙʔτɻ goίϚϯυʹϏϧυɾςετɾίʔυ੔ܗɾੜ੒ͳͲͷπʔϧ͕ू໿

Slide 17

Slide 17 text

ͳͥॻ͘ͷ͔ɿ ৺Λແʹͯ͠ॻ͘ͷʹௐ౓ྑ͍͔Β ॆ࣮ͨ͠πʔϧ܈ʹΑΔαϙʔτɻ ੩తܕ෇͚ͳμοΫλΠϐϯάͰ໘౗͘͘͞ͳ͍ɻ ίϯύΠϧ࣌ʹܕνΣοΫͯ͠΄͍͚͠Ͳɺؾ࣋ͪ͸--࢖͍Ͱ͍͍ͨ goίϚϯυʹϏϧυɾςετɾίʔυ੔ܗɾੜ੒ͳͲͷπʔϧ͕ू໿

Slide 18

Slide 18 text

ͳͥॻ͘ͷ͔ɿ ৺Λແʹͯ͠ॻ͘ͷʹௐ౓ྑ͍͔Β ॆ࣮ͨ͠πʔϧ܈ʹΑΔαϙʔτɻ ੩తܕ෇͚ͳμοΫλΠϐϯάͰ໘౗͘͘͞ͳ͍ɻ ࠇຐज़͕ͳ͍ɻݟͨ໨ͦͷ··ʹಈ͘ɻ ίϯύΠϧ࣌ʹܕνΣοΫͯ͠΄͍͚͠Ͳɺؾ࣋ͪ͸--࢖͍Ͱ͍͍ͨ ҉໧తܕม׵ͱ͔ϚΫϩͱ͔ڧྗ͚ͩͲɺͦΕΑΓ͸ಡΈ΍͢͞ॏࢹ goίϚϯυʹϏϧυɾςετɾίʔυ੔ܗɾੜ੒ͳͲͷπʔϧ͕ू໿

Slide 19

Slide 19 text

ࢲͷ৔߹ɿPython͔ΒGolang΁

Slide 20

Slide 20 text

ࢲͷ৔߹ɿPython͔ΒGolang΁ Python͸ྑ͍ͷ͕ͩʜ

Slide 21

Slide 21 text

ࢲͷ৔߹ɿPython͔ΒGolang΁ ɾ੩తܕνΣοΫ͍ͨ͠ Python͸ྑ͍ͷ͕ͩʜ

Slide 22

Slide 22 text

ࢲͷ৔߹ɿPython͔ΒGolang΁ ɾ੩తܕνΣοΫ͍ͨ͠ ɾ͋Δఔ౓ߴ଎ʹಈ͔͍ͨ͠ Python͸ྑ͍ͷ͕ͩʜ

Slide 23

Slide 23 text

ࢲͷ৔߹ɿPython͔ΒGolang΁ ɾ੩తܕνΣοΫ͍ͨ͠ ɾ͋Δఔ౓ߴ଎ʹಈ͔͍ͨ͠ ɾฒߦॲཧɾฒྻॲཧΛָʹॻ͖͍ͨ Python͸ྑ͍ͷ͕ͩʜ

Slide 24

Slide 24 text

ࢲͷ৔߹ɿPython͔ΒGolang΁ ɾ੩తܕνΣοΫ͍ͨ͠ ɾ͋Δఔ౓ߴ଎ʹಈ͔͍ͨ͠ ɾฒߦॲཧɾฒྻॲཧΛָʹॻ͖͍ͨ ɾ͚ͲɺίϯύΠϧ΍ϏϧυπʔϧͰਏ͘ͳΓͨ͘ͳ͍ Python͸ྑ͍ͷ͕ͩʜ

Slide 25

Slide 25 text

ࢲͷ৔߹ɿPython͔ΒGolang΁ ɾ੩తܕνΣοΫ͍ͨ͠ ɾ͋Δఔ౓ߴ଎ʹಈ͔͍ͨ͠ ɾฒߦॲཧɾฒྻॲཧΛָʹॻ͖͍ͨ ɾ͚ͲɺίϯύΠϧ΍ϏϧυπʔϧͰਏ͘ͳΓͨ͘ͳ͍ ͦΕɺGolangͰͰ͖ΔΑʂ Python͸ྑ͍ͷ͕ͩʜ

Slide 26

Slide 26 text

୯७Ͱ෼͔Γ΍͍͢πʔϧ܈

Slide 27

Slide 27 text

HPSVOͱΓ͋͑ͣίϯύΠϧ࣮ͯ͠ߦ͢Δ

Slide 28

Slide 28 text

HPSVOͱΓ͋͑ͣίϯύΠϧ࣮ͯ͠ߦ͢Δ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main() { 8 fmt.Println("Hello, world!") 9 } ίϯύΠϧɾ࣮ߦΛ͓͜ͳ͏ɻ ɾίϯύΠϧ͸ߴ଎ ɾ͍ΘΏΔ--తͳؾ࣋ͪͰ࣮ߦ

Slide 29

Slide 29 text

HPSVOͱΓ͋͑ͣίϯύΠϧ࣮ͯ͠ߦ͢Δ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main() { 8 fmt.Println("Hello, world!") 9 } $ go run main.go ίϯύΠϧɾ࣮ߦΛ͓͜ͳ͏ɻ ɾίϯύΠϧ͸ߴ଎ ɾ͍ΘΏΔ--తͳؾ࣋ͪͰ࣮ߦ

Slide 30

Slide 30 text

HPSVOͱΓ͋͑ͣίϯύΠϧ࣮ͯ͠ߦ͢Δ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main() { 8 fmt.Println("Hello, world!") 9 } $ go run main.go ίϯύΠϧɾ࣮ߦΛ͓͜ͳ͏ɻ ɾίϯύΠϧ͸ߴ଎ ɾ͍ΘΏΔ--తͳؾ࣋ͪͰ࣮ߦ ʮͱΓ࣮͋͑ͣߦʯ͕ؾܰʹͰ͖Δ $ go run main.go Hello, world!

Slide 31

Slide 31 text

HPSVOͱΓ͋͑ͣίϯύΠϧ࣮ͯ͠ߦ͢Δ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main() { 8 fmt.Println("Hello, world!") 9 } $ go run main.go $ go run main.go Hello, world! ίϯύΠϧɾ࣮ߦΛ͓͜ͳ͏ɻ ɾίϯύΠϧ͸ߴ଎ ɾ͍ΘΏΔ--తͳؾ࣋ͪͰ࣮ߦ ։ൃऀͰ͋ΔRob Pikeࢯ͍Θ͘ʮಛผ଎͍Θ͚Ͱ͸ͳ͍ɻ஗͘ͳΔ͜ͱΛ΍ͬͯͳ͍͚ͩɻʯͱͷ͜ͱ ʮͱΓ࣮͋͑ͣߦʯ͕ؾܰʹͰ͖Δ https://twitter.com/Morikuma_Works/status/538961275779162112

Slide 32

Slide 32 text

HPGNUίʔυΛ੔͑Δ

Slide 33

Slide 33 text

HPGNUίʔυΛ੔͑Δ ίʔυϑΥʔϚολʔ͕ެࣜʹఏڙ͞Ε͍ͯΔɻ

Slide 34

Slide 34 text

HPGNUίʔυΛ੔͑Δ ίʔυϑΥʔϚολʔ͕ެࣜʹఏڙ͞Ε͍ͯΔɻ ɾελΠϧͷ౷Ұͱ͍͏ ॏཁ͚ͩͲ ෆໟͳٞ࿦͕ى͖ͳ͍ɻ

Slide 35

Slide 35 text

HPGNUίʔυΛ੔͑Δ ίʔυϑΥʔϚολʔ͕ެࣜʹఏڙ͞Ε͍ͯΔɻ ɾελΠϧͷ౷Ұͱ͍͏ ॏཁ͚ͩͲ ෆໟͳٞ࿦͕ى͖ͳ͍ɻ ɾίʔυΛॻ͘͜ͱʹूதͰ͖Δɻอଘ࣌ʹࣗಈͰϑΥʔϚοτɻ

Slide 36

Slide 36 text

HPGNUίʔυΛ੔͑Δ 1 package main 2 3 4 import ( 5 "fmt" 6 ) 7 8 func main(){ 9 fmt.Println( "Hello, world!") } ίʔυϑΥʔϚολʔ͕ެࣜʹఏڙ͞Ε͍ͯΔɻ ɾελΠϧͷ౷Ұͱ͍͏ ॏཁ͚ͩͲ ෆໟͳٞ࿦͕ى͖ͳ͍ɻ ɾίʔυΛॻ͘͜ͱʹूதͰ͖Δɻอଘ࣌ʹࣗಈͰϑΥʔϚοτɻ

Slide 37

Slide 37 text

HPGNUίʔυΛ੔͑Δ 1 package main 2 3 4 import ( 5 "fmt" 6 ) 7 8 func main(){ 9 fmt.Println( "Hello, world!") } ίʔυϑΥʔϚολʔ͕ެࣜʹఏڙ͞Ε͍ͯΔɻ $ go fmt main.go ɾελΠϧͷ౷Ұͱ͍͏ ॏཁ͚ͩͲ ෆໟͳٞ࿦͕ى͖ͳ͍ɻ ɾίʔυΛॻ͘͜ͱʹूதͰ͖Δɻอଘ࣌ʹࣗಈͰϑΥʔϚοτɻ

Slide 38

Slide 38 text

HPGNUίʔυΛ੔͑Δ 1 package main 2 3 4 import ( 5 "fmt" 6 ) 7 8 func main(){ 9 fmt.Println( "Hello, world!") } 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main() { 8 fmt.Println("Hello, world!") 9 } ίʔυϑΥʔϚολʔ͕ެࣜʹఏڙ͞Ε͍ͯΔɻ $ go fmt main.go ɾελΠϧͷ౷Ұͱ͍͏ ॏཁ͚ͩͲ ෆໟͳٞ࿦͕ى͖ͳ͍ɻ ɾίʔυΛॻ͘͜ͱʹूதͰ͖Δɻอଘ࣌ʹࣗಈͰϑΥʔϚοτɻ

Slide 39

Slide 39 text

HPHFUύοέʔδΛऔಘͯ͠Πϯετʔϧ

Slide 40

Slide 40 text

HPHFUύοέʔδΛऔಘͯ͠Πϯετʔϧ $ go get -u github.com/mitsuse/bullet ύοέʔδ໊Λࢦఆ͢Δ͚ͩʂϏϧυ͔ΒΠϯετʔϧ·Ͱ׬ྃ͢Δɻ

Slide 41

Slide 41 text

HPHFUύοέʔδΛऔಘͯ͠Πϯετʔϧ $ go get -u github.com/mitsuse/bullet ύοέʔδ໊Λࢦఆ͢Δ͚ͩʂϏϧυ͔ΒΠϯετʔϧ·Ͱ׬ྃ͢Δɻ Makefile૬౰ϑΝΠϧ΍ґଘؔ܎Λఆٛ͢ΔϑΝΠϧ͕ଘࡏ͠ͳ͍ɻ

Slide 42

Slide 42 text

HPHFUύοέʔδΛऔಘͯ͠Πϯετʔϧ $ go get -u github.com/mitsuse/bullet ύοέʔδ໊Λࢦఆ͢Δ͚ͩʂϏϧυ͔ΒΠϯετʔϧ·Ͱ׬ྃ͢Δɻ 1 import ( 2 ... 3 "github.com/codegangsta/cli" 4 "github.com/mitsuse/pushbullet-go" 5 "github.com/mitsuse/pushbullet-go/requests" 6 ) Makefile૬౰ϑΝΠϧ΍ґଘؔ܎Λఆٛ͢ΔϑΝΠϧ͕ଘࡏ͠ͳ͍ɻ

Slide 43

Slide 43 text

HPHFUύοέʔδΛऔಘͯ͠Πϯετʔϧ $ go get -u github.com/mitsuse/bullet ύοέʔδ໊Λࢦఆ͢Δ͚ͩʂϏϧυ͔ΒΠϯετʔϧ·Ͱ׬ྃ͢Δɻ 1 import ( 2 ... 3 "github.com/codegangsta/cli" 4 "github.com/mitsuse/pushbullet-go" 5 "github.com/mitsuse/pushbullet-go/requests" 6 ) import͞ΕͯΔύοέʔδ΋औಘɾϏϧυ Makefile૬౰ϑΝΠϧ΍ґଘؔ܎Λఆٛ͢ΔϑΝΠϧ͕ଘࡏ͠ͳ͍ɻ

Slide 44

Slide 44 text

HPHFUύοέʔδΛऔಘͯ͠Πϯετʔϧ $ go get -u github.com/mitsuse/bullet ύοέʔδ໊Λࢦఆ͢Δ͚ͩʂϏϧυ͔ΒΠϯετʔϧ·Ͱ׬ྃ͢Δɻ ґଘؔ܎ͷ؅ཧ͸ɺίʔυதͷimport͕݉Ͷ͍ͯΔɻແବ͕ͳ͍ɻ 1 import ( 2 ... 3 "github.com/codegangsta/cli" 4 "github.com/mitsuse/pushbullet-go" 5 "github.com/mitsuse/pushbullet-go/requests" 6 ) import͞ΕͯΔύοέʔδ΋औಘɾϏϧυ Makefile૬౰ϑΝΠϧ΍ґଘؔ܎Λఆٛ͢ΔϑΝΠϧ͕ଘࡏ͠ͳ͍ɻ

Slide 45

Slide 45 text

ܕγεςϜ͕୯७ ܕʹ֊૚ؔ܎͕ͳ͍

Slide 46

Slide 46 text

ߏ଄ମ(struct)ɿ Goͷߏ଄ମ͸ϝιουΛ࣋ͭ

Slide 47

Slide 47 text

ߏ଄ମ(struct)ɿ Goͷߏ଄ମ͸ϝιουΛ࣋ͭ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 type Cat struct { 8 name string 9 } 10 11 func (c *Cat) Name() string { 12 return c.name 13 } 14 15 func main() { 16 cat := &Cat{ 17 name: "Rentaro", 18 } 19 20 fmt.Println(cat.Name()) 21 } ߏ଄ମͷΠϯελϯε͔Βυοτ෇͖Ͱϝιουݺͼग़͕͠Մೳɻ

Slide 48

Slide 48 text

ߏ଄ମ(struct)ɿ Goͷߏ଄ମ͸ϝιουΛ࣋ͭ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 type Cat struct { 8 name string 9 } 10 11 func (c *Cat) Name() string { 12 return c.name 13 } 14 15 func main() { 16 cat := &Cat{ 17 name: "Rentaro", 18 } 19 20 fmt.Println(cat.Name()) 21 } ߏ଄ମͱϑΟʔϧυ ߏ଄ମͷΠϯελϯε͔Βυοτ෇͖Ͱϝιουݺͼग़͕͠Մೳɻ

Slide 49

Slide 49 text

ߏ଄ମ(struct)ɿ Goͷߏ଄ମ͸ϝιουΛ࣋ͭ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 type Cat struct { 8 name string 9 } 10 11 func (c *Cat) Name() string { 12 return c.name 13 } 14 15 func main() { 16 cat := &Cat{ 17 name: "Rentaro", 18 } 19 20 fmt.Println(cat.Name()) 21 } ߏ଄ମͱϑΟʔϧυ ߏ଄ମ͸ϝιουΛ࣋ͭ ߏ଄ମͷΠϯελϯε͔Βυοτ෇͖Ͱϝιουݺͼग़͕͠Մೳɻ

Slide 50

Slide 50 text

ߏ଄ମ(struct)ɿ Goͷߏ଄ମ͸ϝιουΛ࣋ͭ 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 type Cat struct { 8 name string 9 } 10 11 func (c *Cat) Name() string { 12 return c.name 13 } 14 15 func main() { 16 cat := &Cat{ 17 name: "Rentaro", 18 } 19 20 fmt.Println(cat.Name()) 21 } ߏ଄ମͱϑΟʔϧυ ߏ଄ମ͸ϝιουΛ࣋ͭ {}͔newͰੜ੒ɾॳظԽ ߏ଄ମͷΠϯελϯε͔Βυοτ෇͖Ͱϝιουݺͼग़͕͠Մೳɻ

Slide 51

Slide 51 text

ΠϯλʔϑΣʔε (interface)ɿ ϝιουఆٛͷू·Γ

Slide 52

Slide 52 text

ΠϯλʔϑΣʔε (interface)ɿ ϝιουఆٛͷू·Γ 1 type Named interface { 2 Name() string 3 } 4 5 type Cat struct { 6 name string 7 } 8 9 func (c *Cat) Name() string { 10 return c.name 11 } .. 21 func printName(n Named) { 22 fmt.Println(n.Name()) 23 } ΠϯλʔϑΣʔεͰϝιουͷγάωνϟΛఆٛ͢Δɻ

Slide 53

Slide 53 text

ΠϯλʔϑΣʔε (interface)ɿ ϝιουఆٛͷू·Γ 1 type Named interface { 2 Name() string 3 } 4 5 type Cat struct { 6 name string 7 } 8 9 func (c *Cat) Name() string { 10 return c.name 11 } .. 21 func printName(n Named) { 22 fmt.Println(n.Name()) 23 } ΠϯλʔϑΣʔε͸ϝιου܈Λఆٛ ΠϯλʔϑΣʔεͰϝιουͷγάωνϟΛఆٛ͢Δɻ

Slide 54

Slide 54 text

ΠϯλʔϑΣʔε (interface)ɿ ϝιουఆٛͷू·Γ 1 type Named interface { 2 Name() string 3 } 4 5 type Cat struct { 6 name string 7 } 8 9 func (c *Cat) Name() string { 10 return c.name 11 } .. 21 func printName(n Named) { 22 fmt.Println(n.Name()) 23 } ΠϯλʔϑΣʔε͸ϝιου܈Λఆٛ *Cat͸Name()ϝιουΛ࣋ͭ ΠϯλʔϑΣʔεͰϝιουͷγάωνϟΛఆٛ͢Δɻ

Slide 55

Slide 55 text

ΠϯλʔϑΣʔε (interface)ɿ ϝιουఆٛͷू·Γ 1 type Named interface { 2 Name() string 3 } 4 5 type Cat struct { 6 name string 7 } 8 9 func (c *Cat) Name() string { 10 return c.name 11 } .. 21 func printName(n Named) { 22 fmt.Println(n.Name()) 23 } ΠϯλʔϑΣʔε͸ϝιου܈Λఆٛ *Cat͸Name()ϝιουΛ࣋ͭ *Cat͸NamedΛຬ͍ͨͯ͠Δ ΠϯλʔϑΣʔεͰϝιουͷγάωνϟΛఆٛ͢Δɻ

Slide 56

Slide 56 text

ΠϯλʔϑΣʔε (interface)ɿ ϝιουఆٛͷू·Γ 1 type Named interface { 2 Name() string 3 } 4 5 type Cat struct { 6 name string 7 } 8 9 func (c *Cat) Name() string { 10 return c.name 11 } .. 21 func printName(n Named) { 22 fmt.Println(n.Name()) 23 } ΠϯλʔϑΣʔε͸ϝιου܈Λఆٛ ΠϯλʔϑΣʔεͰϝιουͷγάωνϟΛఆٛ͢Δɻ ΠϯλʔϑΣʔε͕࣋ͭϝιου܈ͷ࣮૷Λɺߏ଄ମ͕͍࣋ͬͯΔɻ ߏ଄ମ͸ɺͦͷΠϯλʔϑΣʔεܕͱͯ͠ར༻Ͱ͖Δɻ ࣮૷ͯ͠Δ͜ͱΛ໌ࣔ͠ͳͯ͘ྑ͍ɻ੩తͳμοΫλΠϐϯάɻ *Cat͸Name()ϝιουΛ࣋ͭ *Cat͸NamedΛຬ͍ͨͯ͠Δ

Slide 57

Slide 57 text

ߏ଄ମຒΊࠐΈ (struct embedding)ɿ ҠৡʹΑΔΠϯλʔϑΣʔεͷ࣮૷ύλʔϯ

Slide 58

Slide 58 text

ߏ଄ମຒΊࠐΈ (struct embedding)ɿ ҠৡʹΑΔΠϯλʔϑΣʔεͷ࣮૷ύλʔϯ 1 type Named interface { 2 Name() string 3 } 4 5 type Animal struct { 6 name string 7 } 8 9 func (a *Animal) Name() string { 10 return a.name 11 } 12 13 type Cat struct { 14 *Animal 15 } Golangʹ͸ܧঝ͸ͳ͍ɻ ߏ଄ମຒΊࠐΈͰҠৡͯ͠ɺΠϯλʔ ϑΣʔεΛຬͨ͢ύλʔϯɻ

Slide 59

Slide 59 text

ߏ଄ମຒΊࠐΈ (struct embedding)ɿ ҠৡʹΑΔΠϯλʔϑΣʔεͷ࣮૷ύλʔϯ 1 type Named interface { 2 Name() string 3 } 4 5 type Animal struct { 6 name string 7 } 8 9 func (a *Animal) Name() string { 10 return a.name 11 } 12 13 type Cat struct { 14 *Animal 15 } *Animal͸Name()ϝιουΛ࣋ͭ ߏ଄ମຒΊࠐΈͰҠৡͯ͠ɺΠϯλʔ ϑΣʔεΛຬͨ͢ύλʔϯɻ Golangʹ͸ܧঝ͸ͳ͍ɻ

Slide 60

Slide 60 text

ߏ଄ମຒΊࠐΈ (struct embedding)ɿ ҠৡʹΑΔΠϯλʔϑΣʔεͷ࣮૷ύλʔϯ 1 type Named interface { 2 Name() string 3 } 4 5 type Animal struct { 6 name string 7 } 8 9 func (a *Animal) Name() string { 10 return a.name 11 } 12 13 type Cat struct { 14 *Animal 15 } ಗ໊ϑΟʔϧυ*Animalͷϝιου͸ɺ *Catͷॴ༗෺ͷΑ͏ʹΞΫηεͰ͖Δ ߏ଄ମຒΊࠐΈͰҠৡͯ͠ɺΠϯλʔ ϑΣʔεΛຬͨ͢ύλʔϯɻ Golangʹ͸ܧঝ͸ͳ͍ɻ *Animal͸Name()ϝιουΛ࣋ͭ

Slide 61

Slide 61 text

ߏ଄ମຒΊࠐΈ (struct embedding)ɿ ҠৡʹΑΔΠϯλʔϑΣʔεͷ࣮૷ύλʔϯ 1 type Named interface { 2 Name() string 3 } 4 5 type Animal struct { 6 name string 7 } 8 9 func (a *Animal) Name() string { 10 return a.name 11 } 12 13 type Cat struct { 14 *Animal 15 } ߏ଄ମຒΊࠐΈͰҠৡͯ͠ɺΠϯλʔ ϑΣʔεΛຬͨ͢ύλʔϯɻ ܕʹ֊૚ؔ܎͕ͳ͍ɻΠϯλʔϑΣʔεΛຬ͍ͨͯ͠Δ͔͕ॏཁɻ Golangʹ͸ܧঝ͸ͳ͍ɻ ಗ໊ϑΟʔϧυ*Animalͷϝιου͸ɺ *Catͷॴ༗෺ͷΑ͏ʹΞΫηεͰ͖Δ *Animal͸Name()ϝιουΛ࣋ͭ

Slide 62

Slide 62 text

഑෍ํ๏͕୯७

Slide 63

Slide 63 text

୯ҰόΠφϦɾΫϩείϯύΠϧͰ഑෍͠΍͍͢

Slide 64

Slide 64 text

୯ҰόΠφϦɾΫϩείϯύΠϧͰ഑෍͠΍͍͢ ࣮ߦՄೳϑΝΠϧ͸ɺ୯ҰͷϑΝΠϧʹ·ͱΊΒΕΔɻ ɾجຊతʹ͸ੜ੒͞ΕͨόΠφϦΛ഑෍͢Ε͹ྑ͍ɻ

Slide 65

Slide 65 text

୯ҰόΠφϦɾΫϩείϯύΠϧͰ഑෍͠΍͍͢ ࣮ߦՄೳϑΝΠϧ͸ɺ୯ҰͷϑΝΠϧʹ·ͱΊΒΕΔɻ ɾجຊతʹ͸ੜ੒͞ΕͨόΠφϦΛ഑෍͢Ε͹ྑ͍ɻ ؀ڥม਺ͰOSͱΞʔΩςΫνϟΛࢦఆ͢Δ͚ͩɻ

Slide 66

Slide 66 text

୯ҰόΠφϦɾΫϩείϯύΠϧͰ഑෍͠΍͍͢ $ GOOS=windows GOARCH=amd64 go build main.go ؀ڥม਺ͰOSͱΞʔΩςΫνϟΛࢦఆ͢Δ͚ͩɻ ྫ͑͹ɺOS X্ͰɺWindowsόΠφϦΛग़ྗ͢Δɻ ࣮ߦՄೳϑΝΠϧ͸ɺ୯ҰͷϑΝΠϧʹ·ͱΊΒΕΔɻ ɾجຊతʹ͸ੜ੒͞ΕͨόΠφϦΛ഑෍͢Ε͹ྑ͍ɻ

Slide 67

Slide 67 text

୯ҰόΠφϦɾΫϩείϯύΠϧͰ഑෍͠΍͍͢ ྫ͑͹ɺOS X্ͰɺWindowsόΠφϦΛग़ྗ͢Δɻ ࣮ߦՄೳϑΝΠϧ͸ɺ୯ҰͷϑΝΠϧʹ·ͱΊΒΕΔɻ ɾجຊతʹ͸ੜ੒͞ΕͨόΠφϦΛ഑෍͢Ε͹ྑ͍ɻ ͦΕͧΕͷ؀ڥ޲͚ʹΫϩείϯύΠϧͯ͠όΠφϦΛҰͭ഑෍ͰOK ؀ڥม਺ͰOSͱΞʔΩςΫνϟΛࢦఆ͢Δ͚ͩɻ $ GOOS=windows GOARCH=amd64 go build main.go

Slide 68

Slide 68 text

Մಡੑ͸େ੾

Slide 69

Slide 69 text

“No magic”Ͱ͋Δ

Slide 70

Slide 70 text

“No magic”Ͱ͋Δ ͍ΘΏΔʮࠇຐज़ʯతͳػೳ͸࣮૷͞Εͳ͍

Slide 71

Slide 71 text

“No magic”Ͱ͋Δ ɾ҉໧తܕม׵ ɾϚΫϩ ɾ҉໧తͳύϥϝʔλʔ ͍ΘΏΔʮࠇຐज़ʯతͳػೳ͸࣮૷͞Εͳ͍

Slide 72

Slide 72 text

“No magic”Ͱ͋Δ ɾ҉໧తܕม׵ ɾϚΫϩ ɾ҉໧తͳύϥϝʔλʔ ͍ΘΏΔʮࠇຐज़ʯతͳػೳ͸࣮૷͞Εͳ͍ ʮࠇຐज़ʯ͸ڧྗ͚ͩͲɺద੾ʹ࢖͏ͷ͕೉͍͠ɻ

Slide 73

Slide 73 text

“No magic”Ͱ͋Δ ɾ҉໧తܕม׵ ɾϚΫϩ ɾ҉໧తͳύϥϝʔλʔ ͍ΘΏΔʮࠇຐज़ʯతͳػೳ͸࣮૷͞Εͳ͍ ίʔυ͕ݟͨ໨ͦͷ··ʹ࣮ߦ͞ΕΔ͜ͱ͕ॏࢹ͞ΕΔɻ ʮࠇຐज़ʯ͸ڧྗ͚ͩͲɺద੾ʹ࢖͏ͷ͕೉͍͠ɻ

Slide 74

Slide 74 text

“No magic”Ͱ͋Δ ɾ҉໧తܕม׵ ɾϚΫϩ ɾ҉໧తͳύϥϝʔλʔ ͍ΘΏΔʮࠇຐज़ʯతͳػೳ͸࣮૷͞Εͳ͍ ίʔυ͕ݟͨ໨ͦͷ··ʹ࣮ߦ͞ΕΔ͜ͱ͕ॏࢹ͞ΕΔɻ ʮࠇຐज़ʯ͸ڧྗ͚ͩͲɺద੾ʹ࢖͏ͷ͕೉͍͠ɻ ෳࡶͳػೳΛͱΓ͜·ͳ͍͜ͱͰݴޠͦͷ΋ͷΛγϯϓϧʹอͭɻ

Slide 75

Slide 75 text

“No magic”Ͱ͋Δ ɾ҉໧తܕม׵ ɾϚΫϩ ɾ҉໧తͳύϥϝʔλʔ ͍ΘΏΔʮࠇຐज़ʯతͳػೳ͸࣮૷͞Εͳ͍ ίʔυ͕ݟͨ໨ͦͷ··ʹ࣮ߦ͞ΕΔ͜ͱ͕ॏࢹ͞ΕΔɻ ʮࠇຐज़ʯ͸ڧྗ͚ͩͲɺద੾ʹ࢖͏ͷ͕೉͍͠ɻ ෳࡶͳػೳΛͱΓ͜·ͳ͍͜ͱͰݴޠͦͷ΋ͷΛγϯϓϧʹอͭɻ ࠇຐज़͕ೖΔ༨஍͕গͳ͍ͷͰՄಡੑͱ৴པੑ͕ҡ࣋͞Ε΍͍͢

Slide 76

Slide 76 text

خ͘͠ͳ͍ͱ͜Ζ

Slide 77

Slide 77 text

خ͘͠ͳ͍ͱ͜Ζɿ
 δΣωϦΫε͕ͳ͍ɾόʔδϣϯݻఆ͕ਏ͍

Slide 78

Slide 78 text

خ͘͠ͳ͍ͱ͜Ζɿ
 δΣωϦΫε͕ͳ͍ɾόʔδϣϯݻఆ͕ਏ͍ ɾΠϯλʔϑΣʔεͰ·͔ͳ͑Δέʔε΋ଟ͍͕ɺ೉͍͠৔໘΋ɻ ɾӬٱʹ࣮૷͞Εͳ͍Θ͚Ͱ͸ͳ͍͕ɺޓ׵ੑ্͠͹Β͘͸ͳ͍͔΋ʁ ɾந৅౓ͷߴ͍΋ͷΛॻ͘ͷ͸ਏ͍ɻΉ͠Ζॻ͘΂͖Ͱ͸ͳ͍ɻ δΣωϦΫε૬౰ͷ΋ͷ͸ͳ͍

Slide 79

Slide 79 text

خ͘͠ͳ͍ͱ͜Ζɿ
 δΣωϦΫε͕ͳ͍ɾόʔδϣϯݻఆ͕ਏ͍ ɾݱঢ়ެࣜͰ͸ɺϥΠϒϥϦͷόʔδϣϯΛݻఆ͢Δखஈ͸ͳ͍ɻ ɾgodepͱ͔gopkg.inͱ͔࢖͑͹Ͱ͖Δ͚Ͳɻ ɾGo 1.5Ҏ߱Ͱͪΐͬͱঢ়گมΘΔ͔΋ʁ ɾΠϯλʔϑΣʔεͰ·͔ͳ͑Δέʔε΋ଟ͍͕ɺ೉͍͠৔໘΋ɻ δΣωϦΫε૬౰ͷ΋ͷ͸ͳ͍ ϥΠϒϥϦͷόʔδϣϯͷݻఆ͕೉͍͠ ɾӬٱʹ࣮૷͞Εͳ͍Θ͚Ͱ͸ͳ͍͕ɺޓ׵ੑ্͠͹Β͘͸ͳ͍͔΋ʁ ɾந৅౓ͷߴ͍΋ͷΛॻ͘ͷ͸ਏ͍ɻΉ͠Ζॻ͘΂͖Ͱ͸ͳ͍ɻ

Slide 80

Slide 80 text

Ұ൪େ੾ͳ͜ͱ

Slide 81

Slide 81 text

Gopher͸͔Θ͍͍

Slide 82

Slide 82 text

·ͱΊɿπʔϧͱࢥ૝Ͱ৺ΛແʹͰ͖Δݴޠ ॆ࣮ͨ͠πʔϧ܈ʹΑΔαϙʔτɻ ੩తܕ෇͚ͳμοΫλΠϐϯάͰ໘౗͘͘͞ͳ͍ɻ ࠇຐज़͕ͳ͍ɻݟͨ໨ͦͷ··ʹಈ͘ɻ goίϚϯυʹϏϧυɾςετɾίʔυ੔ܗɾੜ੒ͳͲͷπʔϧ͕ू໿ ίϯύΠϧ࣌ʹܕνΣοΫͯ͠΄͍͚͠Ͳɺؾ࣋ͪ͸--࢖͍Ͱ͍͍ͨ ҉໧తܕม׵ͱ͔ϚΫϩͱ͔ڧྗ͚ͩͲɺͦΕΑΓ͸ಡΈ΍͢͞ॏࢹ