Skip to Content
러닝 Go : Go 개발자처럼 생각하는 방법
book

러닝 Go : Go 개발자처럼 생각하는 방법

by 존 보드너, 윤대석
February 2022
Beginner to intermediate
452 pages
10h 48m
Korean
Hanbit Media, Inc.
Content preview from 러닝 Go : Go 개발자처럼 생각하는 방법
251
9
모듈, 패키지 그리고 임포트
crypto
/
rand
crand
라는 이름으로 가져왔다. 이것은 패키지 내에 선언된
rand
라는 이름을
재정의하는 것이다.
math
/
rand
는 정상적으로 가져올 수 있다.
seedRand
함수를 살펴볼 때,
math
/
rand
내에 식별자를 접근하는 경우에는
rand
접두사를 사용하고
crypto
/
rand
패키지
의 것을 접근할 때는
crand
접두사를 사용한다는 것을 볼 수 있다.
func seedRand() *rand.Rand {
var b [8]byte
_, err := crand.Read(b[:])
if err != nil {
panic(“cannot seed with cryptographic random number generator”)
}
r := rand.New(rand.NewSource(int64(binary.LittleEndian.Uint64(b[:]))))
return r
}
NOTE
_ 패키지 이름으로 사용가능한 두 개의 다른 심볼이 있다. 패키지 이름으로
.
을 사용하면 현재 패키
지의 네임스페이스로 가져온 패키지의 노출된 모든 심볼을 위치시킨다. 그것들을 사용할 때는 패키지 이름을
붙일 필요가 없다. 이는 단순하게 이름만 보고 현재 패키지에서 정의한 것인지 아니면 가져온 패키지에 선언
된 것인지 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

효율적인 리눅스 명령어 사용의 기술

효율적인 리눅스 명령어 사용의 기술

Daniel J Barrett

Publisher Resources

ISBN: 9791162245309