SlideShare a Scribd company logo
golang tour 
suhyunjun@gmail.com / 전수현
golang history 
● 2009년 11월 발표 
● 구글 엔지니어들에 의해 개발 
● 최신 안정된 릴리즈(stable) 버전 1.3.3 
● 영향을 받은 언어 : C, Limbo, Modula, Newsqueak, Oberon, 파스칼 
● 문법 : C와 비슷 
● 정적 타입 컴파일 언어의 효율성과 동적 언어처럼 쉬운 프로그래밍을 할 수 있도록 하는 것 
을 목표로 한 가비지 컬렉션 기능이 있는 컴파일, 병행성(concurrent) 프로그래밍 언어 
● 목적 
○ 안전성: 타입 안전성과 메모리 안전성 
○ 병행성과 통신을 위한 훌륭한 지원 
○ 효과적인 가비지 컬렉션 
○ 빠른 컴파일
Getting started 
● download 
○ http://golang.org/dl/ 
● setting .bash_profile 
○ $GOROOT 
■ set {golang home path} 
○ $GOPATH 
■ set {golang source code path}
Data types 
● Boolean types, String types, Array types, Map types 
● Numeric types 
○ uint8 the set of all unsigned 8-bit integers (0 to 255) 
○ uint16 the set of all unsigned 16-bit integers (0 to 65535) 
○ uint32 the set of all unsigned 32-bit integers (0 to 4294967295) 
○ uint64 the set of all unsigned 64-bit integers (0 to 18446744073709551615) 
○ int8 the set of all signed 8-bit integers (-128 to 127) 
○ int16 the set of all signed 16-bit integers (-32768 to 32767) 
○ int32 the set of all signed 32-bit integers (-2147483648 to 2147483647) 
○ int64 the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807) 
○ float32 the set of all IEEE-754 32-bit floating-point numbers 
○ float64 the set of all IEEE-754 64-bit floating-point numbers 
○ complex64 the set of all complex numbers with float32 real and imaginary parts 
○ complex128 the set of all complex numbers with float64 real and imaginary parts 
○ byte alias for uint8 
○ rune alias for int32
Hello world 
package main 
import "fmt" 
func main() { 
fmt.Println("hello world") 
} 
$ go run hello-world.go 
hello world 
$ go build hello-world.go // output binary 
$ ls 
hello-world hello-world.go 
$ ./hello-world 
hello world
Variables 
package main 
import "fmt" 
func main() { 
var a string = "initial" // `var` declares 1 or more variables. 
fmt.Println(a) 
var b, c int = 1, 2 // You can declare multiple variables at once. 
fmt.Println(b, c) 
var d = true // Go will infer the type of initialized variables. 
fmt.Println(d) 
……. (next) 
i$1n 2gitoia rlun variables.go true
Variables 
package main 
import "fmt" 
func main() { 
….. 
// Variables declared without a corresponding 
// initialization are _zero-valued_. For example, the 
// zero value for an `int` is `0`. 
var e int 
fmt.Println(e) 
// The `:=` syntax is shorthand for declaring and 
// initializing a variable, e.g. for 
// `var f string = "short"` in this case. 
f := "short" 
fmt.Println(f) 
} 
s$0h goor trun variables.go
For (initial/condition/after) 
package main 
import "fmt" 
func main() { 
i := 1 
for i <= 3 { 
fmt.Println(i) 
i = i + 1 
} 
for j := 7; j <= 9; j++ { 
fmt.Println(j) 
} 
for { 
fmt.Println("loop") 
break 
} 
} 
$ go run for.go 
123789 
loop
If / Else 
package main 
import "fmt" 
func main() { 
if 7%2 == 0 { 
fmt.Println("7 is even") 
} else { 
fmt.Println("7 is odd") 
} 
if 8%4 == 0 { 
fmt.Println("8 is divisible by 4") 
} 
if num := 9; num < 0 { 
fmt.Println(num, "is negative") 
} else if num < 10 { 
fmt.Println(num, "has 1 digit") 
} else { 
fmt.Println(num, "has multiple digits") 
} 
} 
$ go run if-else.go 
7 is odd 
8 is divisible by 4 
9 has 1 digit
Arrays 
package main 
import "fmt" 
func main() { 
var a [5]int 
fmt.Println("emp:", a) 
a[4] = 100 
fmt.Println("set:", a) 
fmt.Println("get:", a[4]) 
fmt.Println("len:", len(a)) 
b := [5]int{1, 2, 3, 4, 5} 
fmt.Println("dcl:", b) 
var twoD [2][3]int 
for i := 0; i < 2; i++ { 
for j := 0; j < 3; j++ { 
twoD[i][j] = i + j 
} 
} 
fmt.Println("2d: ", twoD) 
} 
$ go run arrays.go 
emp: [0 0 0 0 0] 
set: [0 0 0 0 100] 
get: 100 
len: 5 
dcl: [1 2 3 4 5] 
2d: [[0 1 2] [1 2 3]]
Slices (array 보다 많이 사용) 
package main 
import "fmt" 
func main() { 
s := make([]string, 3) 
fmt.Println("emp:", s) 
s[0] = "a" 
s[1] = "b" 
s[2] = "c" 
fmt.Println("set:", s) 
fmt.Println("get:", s[2]) 
fmt.Println("len:", len(s)) 
s = append(s, "d") 
s = append(s, "e", "f") 
fmt.Println("apd:", s) 
…. (next) 
$ go run slices.go 
emp: [ ] 
set: [a b c] 
get: c 
len: 3 
apd: [a b c d e f]
Slices (slice[low:high]) 
package main 
import "fmt" 
func main() { 
… 
c := make([]string, len(s)) 
copy(c, s) 
fmt.Println("cpy:", c) 
l := s[2:5] //elements s[2], s[3], and s[4] 
fmt.Println("sl1:", l) 
l = s[:5] //This slices up to (but excluding) s[5] 
fmt.Println("sl2:", l) 
l = s[2:] //This slices up from (and including) s[2] 
fmt.Println("sl3:", l) 
… (next) 
$ go run slices.go 
cpy: [a b c d e f] 
sl1: [c d e] 
sl2: [a b c d e] 
sl3: [c d e f] 
dcl: [g h i] 
2d: [[0] [1 2] [2 3 4]]
Slices (array 보다 많이 사용) 
package main 
import "fmt" 
func main() { 
… 
t := []string{"g", "h", "i"} 
fmt.Println("dcl:", t) 
twoD := make([][]int, 3) 
for i := 0; i < 3; i++ { 
innerLen := i + 1 
twoD[i] = make([]int, innerLen) 
for j := 0; j < innerLen; j++ { 
twoD[i][j] = i + j 
} 
} 
fmt.Println("2d: ", twoD) 
} 
$ go run slices.go 
dcl: [g h i] 
2d: [[0] [1 2] [2 3 4]]
Slices internals 
Our variable s, created earlier by make([]byte, 5), is structured like this: 
The length is the number
Maps make(map[key-type]val-type) (다른 언어 : hashes 나 dicts로 불리움) 
package main 
import "fmt" 
func main() { 
m := make(map[string]int) 
m["k1"] = 7 
m["k2"] = 13 
fmt.Println("map:", m) 
v1 := m["k1"] 
fmt.Println("v1: ", v1) 
fmt.Println("len:", len(m)) 
… (next) 
} 
$ go run maps.go 
map: map[k1:7 k2:13] 
v1: 7 
len: 2
Maps make(map[key-type]val-type) (다른 언어 : hashes 나 dicts로 불리움) 
package main 
import "fmt" 
func main() { 
… 
delete(m, "k2") 
fmt.Println("map:", m) 
_, prs := m["k2"] 
fmt.Println("prs:", prs) 
n := map[string]int{"foo": 1, "bar": 2} 
fmt.Println("map:", n) 
} 
$ go run slices.go 
map: map[k1:7] 
prs: false 
map: map[foo:1 bar:2]
Defer 
package main 
import "fmt" 
import "os" 
func main() { 
f := createFile("/tmp/defer.txt") 
defer closeFile(f) 
writeFile(f) 
} 
func createFile(p string) *os.File { 
fmt.Println("creating") 
f, err := os.Create(p) 
if err != nil { 
panic(err) 
} 
return f 
} 
… (next) 
$ go run defer.go 
creating 
writing 
closing 
… 
func writeFile(f *os.File) { 
fmt.Println("writing") 
fmt.Fprintln(f, "data") 
} 
func closeFile(f *os.File) { 
fmt.Println("closing") 
f.Close() 
}
Defer 
package main 
import "fmt" 
import "os" 
.... 
func writeFile(f *os.File) { 
fmt.Println("writing") 
fmt.Fprintln(f, "data") 
} 
func closeFile(f *os.File) { 
fmt.Println("closing") 
f.Close() 
} 
$ go run defer.go 
creating 
writing 
closing 
어떤 경로의 함수가 값을 리턴하는지에 관계없이 자원을 해제해 
야만하는 상황을 다루기 위해서는 효과적인 방법. 전형적인 예로 
mutex를 해제하거나 file을 닫는 경우다.
Java vs golang 
모든 짝수번째 숫자를 * 로 치환하시오.(홀수번째 숫자,또는 짝수번째 문자를 치환하면 안됩니다.) 
Example: a1b2cde3~g45hi6 → a*b*cde*~g4*hi6 
java go 
public static void main(String args[]){ 
String text = "a1b2cde3~g45hi6"; 
String replace = ""; 
for(int i=0; i<text.length();i++){ 
char charAt = text.charAt(i); 
if(i % 2 != 0 && Character.isDigit(charAt)){ 
charAt = '*'; 
} 
replace += charAt; 
} 
System.out.print(replace); 
} 
func main() { 
str := "a1b2cde3~g45hi6" 
for index, runeValue := range str { 
if unicode.IsDigit(runeValue) && index % 2 != 0 { 
str = strings.Replace(str, string(runeValue), "*", -1) 
} 
} 
fmt.Printf(str) 
}
참고자료 
● http://en.wikipedia.org/wiki/Go_(programming_language) 
● https://golang.org/doc/go1.3 
● https://gobyexample.com/ 
● http://golang.org/ref/spec#Method_sets 
● https://code.google.com/p/golang-korea/wiki/EffectiveGo 
● http://blog.golang.org/go-slices-usage-and-internals
감사합니다

More Related Content

What's hot

All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
Adam Dudczak
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
Eleanor McHugh
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
Eleanor McHugh
 
10〜30分で何となく分かるGo
10〜30分で何となく分かるGo10〜30分で何となく分かるGo
10〜30分で何となく分かるGoMoriyoshi Koizumi
 
Py3k
Py3kPy3k
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
akaptur
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
Eleanor McHugh
 
Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
Shin Sekaryo
 
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานโปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานknang
 
dplyr
dplyrdplyr
Python 3
Python 3Python 3
Python 3
Andrews Medina
 
Clang2018 class3
Clang2018 class3Clang2018 class3
Clang2018 class3
tagawakiyoshi
 
Data structures
Data structuresData structures
Data structures
gayatrigayu1
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transports
Eleanor McHugh
 
Introduction to F# for the C# developer
Introduction to F# for the C# developerIntroduction to F# for the C# developer
Introduction to F# for the C# developer
njpst8
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...akaptur
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачи
Maxim Kulsha
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
Tor Ivry
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
Raveen Perera
 

What's hot (20)

All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
 
10〜30分で何となく分かるGo
10〜30分で何となく分かるGo10〜30分で何となく分かるGo
10〜30分で何となく分かるGo
 
Py3k
Py3kPy3k
Py3k
 
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
 
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานโปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐาน
 
dplyr
dplyrdplyr
dplyr
 
Python 3
Python 3Python 3
Python 3
 
Clang2018 class3
Clang2018 class3Clang2018 class3
Clang2018 class3
 
Data structures
Data structuresData structures
Data structures
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transports
 
Introduction to F# for the C# developer
Introduction to F# for the C# developerIntroduction to F# for the C# developer
Introduction to F# for the C# developer
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачи
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
 

Similar to Let's golang

Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
go-lang
 
Go Lang Tutorial
Go Lang TutorialGo Lang Tutorial
Go Lang Tutorial
Wei-Ning Huang
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
Mahmoud Masih Tehrani
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
Ishin Vin
 
Golang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewGolang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / Overview
Markus Schneider
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
Anton Arhipov
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
Robert Stern
 
About Go
About GoAbout Go
About Go
Jongmin Kim
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
Geeks Anonymes
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with go
Hean Hong Leong
 
Assignment6
Assignment6Assignment6
Assignment6
Ryan Gogats
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
Guy Komari
 
python beginner talk slide
python beginner talk slidepython beginner talk slide
python beginner talk slide
jonycse
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1Little Tukta Lita
 
Burrowing through go! the book
Burrowing through go! the bookBurrowing through go! the book
Burrowing through go! the book
Vishal Ghadge
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
Python crush course
Python crush coursePython crush course
Python crush course
Mohammed El Rafie Tarabay
 
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
Jan Stamer
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer
Andrea Antonello
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
osfameron
 

Similar to Let's golang (20)

Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
 
Go Lang Tutorial
Go Lang TutorialGo Lang Tutorial
Go Lang Tutorial
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Golang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / OverviewGolang and Eco-System Introduction / Overview
Golang and Eco-System Introduction / Overview
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
About Go
About GoAbout Go
About Go
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with go
 
Assignment6
Assignment6Assignment6
Assignment6
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
python beginner talk slide
python beginner talk slidepython beginner talk slide
python beginner talk slide
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
Burrowing through go! the book
Burrowing through go! the bookBurrowing through go! the book
Burrowing through go! the book
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
Python crush course
Python crush coursePython crush course
Python crush course
 
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 

Recently uploaded

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Let's golang

  • 2. golang history ● 2009년 11월 발표 ● 구글 엔지니어들에 의해 개발 ● 최신 안정된 릴리즈(stable) 버전 1.3.3 ● 영향을 받은 언어 : C, Limbo, Modula, Newsqueak, Oberon, 파스칼 ● 문법 : C와 비슷 ● 정적 타입 컴파일 언어의 효율성과 동적 언어처럼 쉬운 프로그래밍을 할 수 있도록 하는 것 을 목표로 한 가비지 컬렉션 기능이 있는 컴파일, 병행성(concurrent) 프로그래밍 언어 ● 목적 ○ 안전성: 타입 안전성과 메모리 안전성 ○ 병행성과 통신을 위한 훌륭한 지원 ○ 효과적인 가비지 컬렉션 ○ 빠른 컴파일
  • 3. Getting started ● download ○ http://golang.org/dl/ ● setting .bash_profile ○ $GOROOT ■ set {golang home path} ○ $GOPATH ■ set {golang source code path}
  • 4. Data types ● Boolean types, String types, Array types, Map types ● Numeric types ○ uint8 the set of all unsigned 8-bit integers (0 to 255) ○ uint16 the set of all unsigned 16-bit integers (0 to 65535) ○ uint32 the set of all unsigned 32-bit integers (0 to 4294967295) ○ uint64 the set of all unsigned 64-bit integers (0 to 18446744073709551615) ○ int8 the set of all signed 8-bit integers (-128 to 127) ○ int16 the set of all signed 16-bit integers (-32768 to 32767) ○ int32 the set of all signed 32-bit integers (-2147483648 to 2147483647) ○ int64 the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807) ○ float32 the set of all IEEE-754 32-bit floating-point numbers ○ float64 the set of all IEEE-754 64-bit floating-point numbers ○ complex64 the set of all complex numbers with float32 real and imaginary parts ○ complex128 the set of all complex numbers with float64 real and imaginary parts ○ byte alias for uint8 ○ rune alias for int32
  • 5. Hello world package main import "fmt" func main() { fmt.Println("hello world") } $ go run hello-world.go hello world $ go build hello-world.go // output binary $ ls hello-world hello-world.go $ ./hello-world hello world
  • 6. Variables package main import "fmt" func main() { var a string = "initial" // `var` declares 1 or more variables. fmt.Println(a) var b, c int = 1, 2 // You can declare multiple variables at once. fmt.Println(b, c) var d = true // Go will infer the type of initialized variables. fmt.Println(d) ……. (next) i$1n 2gitoia rlun variables.go true
  • 7. Variables package main import "fmt" func main() { ….. // Variables declared without a corresponding // initialization are _zero-valued_. For example, the // zero value for an `int` is `0`. var e int fmt.Println(e) // The `:=` syntax is shorthand for declaring and // initializing a variable, e.g. for // `var f string = "short"` in this case. f := "short" fmt.Println(f) } s$0h goor trun variables.go
  • 8. For (initial/condition/after) package main import "fmt" func main() { i := 1 for i <= 3 { fmt.Println(i) i = i + 1 } for j := 7; j <= 9; j++ { fmt.Println(j) } for { fmt.Println("loop") break } } $ go run for.go 123789 loop
  • 9. If / Else package main import "fmt" func main() { if 7%2 == 0 { fmt.Println("7 is even") } else { fmt.Println("7 is odd") } if 8%4 == 0 { fmt.Println("8 is divisible by 4") } if num := 9; num < 0 { fmt.Println(num, "is negative") } else if num < 10 { fmt.Println(num, "has 1 digit") } else { fmt.Println(num, "has multiple digits") } } $ go run if-else.go 7 is odd 8 is divisible by 4 9 has 1 digit
  • 10. Arrays package main import "fmt" func main() { var a [5]int fmt.Println("emp:", a) a[4] = 100 fmt.Println("set:", a) fmt.Println("get:", a[4]) fmt.Println("len:", len(a)) b := [5]int{1, 2, 3, 4, 5} fmt.Println("dcl:", b) var twoD [2][3]int for i := 0; i < 2; i++ { for j := 0; j < 3; j++ { twoD[i][j] = i + j } } fmt.Println("2d: ", twoD) } $ go run arrays.go emp: [0 0 0 0 0] set: [0 0 0 0 100] get: 100 len: 5 dcl: [1 2 3 4 5] 2d: [[0 1 2] [1 2 3]]
  • 11. Slices (array 보다 많이 사용) package main import "fmt" func main() { s := make([]string, 3) fmt.Println("emp:", s) s[0] = "a" s[1] = "b" s[2] = "c" fmt.Println("set:", s) fmt.Println("get:", s[2]) fmt.Println("len:", len(s)) s = append(s, "d") s = append(s, "e", "f") fmt.Println("apd:", s) …. (next) $ go run slices.go emp: [ ] set: [a b c] get: c len: 3 apd: [a b c d e f]
  • 12. Slices (slice[low:high]) package main import "fmt" func main() { … c := make([]string, len(s)) copy(c, s) fmt.Println("cpy:", c) l := s[2:5] //elements s[2], s[3], and s[4] fmt.Println("sl1:", l) l = s[:5] //This slices up to (but excluding) s[5] fmt.Println("sl2:", l) l = s[2:] //This slices up from (and including) s[2] fmt.Println("sl3:", l) … (next) $ go run slices.go cpy: [a b c d e f] sl1: [c d e] sl2: [a b c d e] sl3: [c d e f] dcl: [g h i] 2d: [[0] [1 2] [2 3 4]]
  • 13. Slices (array 보다 많이 사용) package main import "fmt" func main() { … t := []string{"g", "h", "i"} fmt.Println("dcl:", t) twoD := make([][]int, 3) for i := 0; i < 3; i++ { innerLen := i + 1 twoD[i] = make([]int, innerLen) for j := 0; j < innerLen; j++ { twoD[i][j] = i + j } } fmt.Println("2d: ", twoD) } $ go run slices.go dcl: [g h i] 2d: [[0] [1 2] [2 3 4]]
  • 14. Slices internals Our variable s, created earlier by make([]byte, 5), is structured like this: The length is the number
  • 15. Maps make(map[key-type]val-type) (다른 언어 : hashes 나 dicts로 불리움) package main import "fmt" func main() { m := make(map[string]int) m["k1"] = 7 m["k2"] = 13 fmt.Println("map:", m) v1 := m["k1"] fmt.Println("v1: ", v1) fmt.Println("len:", len(m)) … (next) } $ go run maps.go map: map[k1:7 k2:13] v1: 7 len: 2
  • 16. Maps make(map[key-type]val-type) (다른 언어 : hashes 나 dicts로 불리움) package main import "fmt" func main() { … delete(m, "k2") fmt.Println("map:", m) _, prs := m["k2"] fmt.Println("prs:", prs) n := map[string]int{"foo": 1, "bar": 2} fmt.Println("map:", n) } $ go run slices.go map: map[k1:7] prs: false map: map[foo:1 bar:2]
  • 17. Defer package main import "fmt" import "os" func main() { f := createFile("/tmp/defer.txt") defer closeFile(f) writeFile(f) } func createFile(p string) *os.File { fmt.Println("creating") f, err := os.Create(p) if err != nil { panic(err) } return f } … (next) $ go run defer.go creating writing closing … func writeFile(f *os.File) { fmt.Println("writing") fmt.Fprintln(f, "data") } func closeFile(f *os.File) { fmt.Println("closing") f.Close() }
  • 18. Defer package main import "fmt" import "os" .... func writeFile(f *os.File) { fmt.Println("writing") fmt.Fprintln(f, "data") } func closeFile(f *os.File) { fmt.Println("closing") f.Close() } $ go run defer.go creating writing closing 어떤 경로의 함수가 값을 리턴하는지에 관계없이 자원을 해제해 야만하는 상황을 다루기 위해서는 효과적인 방법. 전형적인 예로 mutex를 해제하거나 file을 닫는 경우다.
  • 19. Java vs golang 모든 짝수번째 숫자를 * 로 치환하시오.(홀수번째 숫자,또는 짝수번째 문자를 치환하면 안됩니다.) Example: a1b2cde3~g45hi6 → a*b*cde*~g4*hi6 java go public static void main(String args[]){ String text = "a1b2cde3~g45hi6"; String replace = ""; for(int i=0; i<text.length();i++){ char charAt = text.charAt(i); if(i % 2 != 0 && Character.isDigit(charAt)){ charAt = '*'; } replace += charAt; } System.out.print(replace); } func main() { str := "a1b2cde3~g45hi6" for index, runeValue := range str { if unicode.IsDigit(runeValue) && index % 2 != 0 { str = strings.Replace(str, string(runeValue), "*", -1) } } fmt.Printf(str) }
  • 20. 참고자료 ● http://en.wikipedia.org/wiki/Go_(programming_language) ● https://golang.org/doc/go1.3 ● https://gobyexample.com/ ● http://golang.org/ref/spec#Method_sets ● https://code.google.com/p/golang-korea/wiki/EffectiveGo ● http://blog.golang.org/go-slices-usage-and-internals