Skip to content

Commit

Permalink
Ran Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
kkweon committed Mar 15, 2021
1 parent 6055f47 commit 1a7e388
Show file tree
Hide file tree
Showing 32 changed files with 1,017 additions and 218 deletions.
1 change: 0 additions & 1 deletion 101-114/101-114.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,3 @@ No Trace
********************************
firstCall->secondCall(10): secondCall->thirdCall(): App Error, State: 99
```

9 changes: 4 additions & 5 deletions 101-114/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Assigned to

* 권용민/@snowmerak
* 강영주/@979156
- 권용민/@snowmerak
- 강영주/@979156

Mandatory reviewer

* 권경모/@kkweon
* 최희재/@gmlwo530
- 권경모/@kkweon
- 최희재/@gmlwo530

## Error Handling 101

Expand All @@ -23,4 +23,3 @@ Mandatory reviewer
> ### Finding the bug 110
>
> ### Wrapping Errors 111
15 changes: 7 additions & 8 deletions 114-128/114-128.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ Go 프로그램을 시작할 때 런타임은 고루틴을 생성한다. 그리

스케줄러가 스케줄링을 하게 되는 4가지 상황이 있다.\[재방문\]

* `go` 키워드를 통해 고루틴들을 생성할 때. 이는 여러개의 프로세서\(P\)를 가지고 있을 때, 스케줄러가 균형을 다시 맞출 수 있다.
* 시스템 콜. 시스템 콜은 이미 항상 발생 하는 경향이 있다.
* 뮤텍스\(Mutex\)를 사용하는 채널. \(추후 학습\)
* 가비지 컬렉션.
- `go` 키워드를 통해 고루틴들을 생성할 때. 이는 여러개의 프로세서\(P\)를 가지고 있을 때, 스케줄러가 균형을 다시 맞출 수 있다.
- 시스템 콜. 시스템 콜은 이미 항상 발생 하는 경향이 있다.
- 뮤텍스\(Mutex\)를 사용하는 채널. \(추후 학습\)
- 가비지 컬렉션.

다시 예제로 돌아와, 스케줄러는 `Gm`이 실행되기까지 충분한 시간이 남았을때, `Gm`을 실행 대기열\(run queue\)에 넣고 `G1`이 해당 `m`에서 실행되도록 혀용한다\(문맥교환\).

Expand Down Expand Up @@ -119,9 +119,9 @@ func main() {
세개의 `Add`, `Done`, `Wait` 메소드를 갖는다. n개의 고루틴은 이 메소드를 동시에 호출 할 수 있고, 모두 직렬화\(serialized\)되어 있다.
* `Add`: 얼마나 많은 고루틴이 있는지 계산한다.
* `Done`: 일부 고루틴이 종료될 예정이므로 값을 감소시킨다.
* `Wait`: 해당 카운트가 0이 될 때까지 프로그램을 유지한다.
- `Add`: 얼마나 많은 고루틴이 있는지 계산한다.
- `Done`: 일부 고루틴이 종료될 예정이므로 값을 감소시킨다.
- `Wait`: 해당 카운트가 0이 될 때까지 프로그램을 유지한다.
```go
var wg sync.WaitGroup
Expand Down Expand Up @@ -402,4 +402,3 @@ E F G H I J K L M N O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
O P Q R S T U V W X Y Z
Terminating Program
```

9 changes: 4 additions & 5 deletions 114-128/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Assigned to

* 이재원/@mumunuu
- 이재원/@mumunuu

Mandatory reviewer

* 권용민/@snowmerak
* 조용래/@dramgonfly
* 신정훈/@shin2jhoon
- 권용민/@snowmerak
- 조용래/@dramgonfly
- 신정훈/@shin2jhoon

## Concurrency 114

Expand All @@ -23,4 +23,3 @@ Mandatory reviewer
> > **Goroutine time slicing 124**
> >
> > **Goroutines and parallelism 126**
5 changes: 2 additions & 3 deletions 128-139/128-139.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

프로그램에 고루틴을 추가하면 복잡도가 엄청나게 올라간다. 고루틴을 언제나 상태없이\(stateless\) 실행할 수는 없기에 조율이 필요하다. 멀티 스레드 소프트웨어를 작성할 때는 사실상 두 가지 선택지가 있다.

* WaitGroup에서 Add와 Done, Wait으로 제어하는 것 처럼, 공유 자원에 대한 접근 상태를 동기화하거나
* 고루틴을 예측 가능하고, 합리적으로 실행이 되도록 만들어야 한다.
- WaitGroup에서 Add와 Done, Wait으로 제어하는 것 처럼, 공유 자원에 대한 접근 상태를 동기화하거나
- 고루틴을 예측 가능하고, 합리적으로 실행이 되도록 만들어야 한다.

채널이 없었을 때는, 아토믹 함수나 mutex를 사용하여 앞서 언급한 두 가지 선택지를 구현하였다. 채널은 간단한 제어 방법을 제공하지만, 대부분의 경우는 아토믹 함수와 mutex를 사용하여 공유 자원에 대한 액세스 동기화를 사용하는 것이 가장 좋은 방법이다. atomic 연산은 Go에서 가장 빠른 방법이다. Go는 메모리에서 한번에 4-8 바이트씩 동기화를 하기 때문이다.

Expand Down Expand Up @@ -482,4 +482,3 @@ func reader(id int) {
아토믹 함수와 뮤텍스는 사용자의 소프트웨어에 대기시간을 만든다. 대기시간은 여러 고루틴 사이에 자원 접근에 대한 조율이 필요할 때 유용하다. Read/Write 뮤텍스는 대기시간을 줄이는 데 유용하다.

뮤텍스를 사용하는 경우, 잠금 이후 최대한 빨리 잠금을 해제해야 한다. 다른 불필요한 행위는 하지 않는 것이 좋다. 때로는 공유 자원을 읽기를 위해 로컬 변수만 사용하는 것으로도 충분하다. 뮤텍스를 적게 사용할수록 좋다. 이를 통해 대기시간을 최소한으로 줄일 수 있다.

7 changes: 3 additions & 4 deletions 128-139/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Assigned to

* 배지원/@baewang
- 배지원/@baewang

Mandatory reviewer

* 조동헌/@davinnovation
* 강영주/@979156
- 조동헌/@davinnovation
- 강영주/@979156

> ## Data race 128
>
Expand All @@ -18,4 +18,3 @@ Mandatory reviewer
> > ### Mutexes 133
> >
> > ### Read/Write Mutex 135
1 change: 0 additions & 1 deletion 139-164/139-164.md
Original file line number Diff line number Diff line change
Expand Up @@ -1053,4 +1053,3 @@ fs 0x0
gs 0x0
exit status 2
```
9 changes: 4 additions & 5 deletions 139-164/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Assigned to

* 조용래/@dreamgonfly
- 조용래/@dreamgonfly

Mandatory reviewer

* 배지원/@baewang
* 정영훈/@aeuveritas
* 신정훈/@shin2jhoon
- 배지원/@baewang
- 정영훈/@aeuveritas
- 신정훈/@shin2jhoon

> ## Channel 139
>
Expand All @@ -31,4 +31,3 @@ Mandatory reviewer
> > ### Buffered channel: Fan Out 153
> >
> > ### Select 157
1 change: 0 additions & 1 deletion 164-173/164-173.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,3 @@ func main() {
2020/08/24 18:37:18 Get https://wwww.ardanlabs.com/blog/post/index.xml:
net/http: request canceled while waiting for connection
```

7 changes: 3 additions & 4 deletions 164-173/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Assigned to

* Mark Hahn/@TangoEnSkai
- Mark Hahn/@TangoEnSkai

Mandatory reviewer

* 권경모/@kkweon
* 정영훈/@aeuveritas
- 권경모/@kkweon
- 정영훈/@aeuveritas

## Patterns 164

Expand All @@ -22,4 +22,3 @@ Mandatory reviewer
> > #### WithTimeout 169
> >
> > #### Request/Response 171
3 changes: 1 addition & 2 deletions 173-191/173-191.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ ok github.com/hoanhan101/ultimate-go/go/testing/web_server/handlers 0.096s

Below is how to test the execution of an internal endpoint without having to stand up the server. Run test using "go test -v -run TestSendJSON"

We are using handlers\_test for package name because we want to make sure we only touch the exported API.
We are using handlers_test for package name because we want to make sure we only touch the exported API.

```go
package handlers_test
Expand Down Expand Up @@ -684,4 +684,3 @@ When we get the response back, we are unmarshaling it from XML to our struct typ
PASS
ok command-line-arguments 0.191s
```

7 changes: 3 additions & 4 deletions 173-191/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Assigned to

* 조동헌/@davinnovation
- 조동헌/@davinnovation

Mandatory reviewer

* 김준희/@juunini
* Mark Hahn/@TangoEnSkai
- 김준희/@juunini
- Mark Hahn/@TangoEnSkai

## Testing and Profiling 173

Expand All @@ -22,4 +22,3 @@ Mandatory reviewer
> > **Web Server 181**
> >
> > **Mock Server 187**
17 changes: 8 additions & 9 deletions 191-199/191-199.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ ok command-line-arguments 7.131s

하위 벤치마크를 할 수 있는 다른 방법들:

* `go test -run none -bench BenchmarkSprintSub/none -benchtime 3s -benchmem`
* `go test -run none -bench BenchmarkSprintSub/format -benchtime 3s -benchmem`
- `go test -run none -bench BenchmarkSprintSub/none -benchtime 3s -benchmem`
- `go test -run none -bench BenchmarkSprintSub/format -benchtime 3s -benchmem`

### 프로파일링\(Profiling\)

Expand Down Expand Up @@ -200,12 +200,12 @@ exit status 2

이번에는 스택 트레이스가 1 word 밖에 보여주지 않는데, 이 4바이트는 32비트 환경에선 half-wold로, 64비트 환경에선 full-word로 표시된다. 예제에 사용된 시스템은 리틀 엔디언을 사용하고 있기 때문에 오른쪽에서 왼쪽으로 읽어야 한다. `0xc419010001` 을 아래와 같이 나타낼 수 있다:

| Bits | Binary | Hex | Value |
| :--- | :--- | :--- | :--- |
| 00-07 | 0000 0001 | 01 | true |
| 08-15 | 0000 0000 | 00 | false |
| 16-23 | 0000 0001 | 01 | true |
| 24-31 | 0001 1001 | 19 | 25 |
| Bits | Binary | Hex | Value |
| :---- | :-------- | :-- | :---- |
| 00-07 | 0000 0001 | 01 | true |
| 08-15 | 0000 0000 | 00 | false |
| 16-23 | 0000 0001 | 01 | true |
| 24-31 | 0001 1001 | 19 | 25 |

#### GODEBUG

Expand Down Expand Up @@ -284,4 +284,3 @@ gc 10 @2.592s 0%: 0.003+11+0.045 ms clock, 0.031+0/5.9/5.2+0.36 ms cpu, 499->499
만약, 당신이 나의 활동 및 프로젝트, 그리고 더 나은 소프트웨어 엔지니어가 되는데 관심이 있다면, 내 웹사이트 [https://hoanhan101.github.io/](https://hoanhan101.github.io/) 에 자유롭게 방문해주시길 바랍니다.

**읽어주셔서 고맙습니다. 행운을 빕니다!**

7 changes: 3 additions & 4 deletions 191-199/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Assigned to

* 김준희/@juunini
- 김준희/@juunini

Mandatory reviewer

* 조동헌/@davinnovation
* Mark Hahn/@TangoEnSkai
- 조동헌/@davinnovation
- Mark Hahn/@TangoEnSkai

### Benchmarking 191

Expand All @@ -28,4 +28,3 @@ Mandatory reviewer
> > **Memory Tracing 196**
## Keep in touch 199

1 change: 0 additions & 1 deletion 20-37/20-37.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,4 +637,3 @@ type users []user
이 구문을 사용하여 `users` 를 새로 정의할 수 있으며, 이는 `users`를 정의하는 두 번째 방법이다. 이처럼 이미 존재하는 타입을 통해, 다른 타입의 타입으로 사용할 수 있다. 이 때 두 타입은 서로 연관성이 없다. 하지만 다음의 코드 `u := make(map[users]int)`와 같이 키로서 사용코자 할 때, 컴파일러는 다음의 오류를 발생시킨다. "맵의 키로써 `users` 타입은 유효하지 않다."
그 이유는, 키로 어떤 것을 사용하던지 그 값은 반드시 비교가능해야 하기 때문이다. 맵이 키의 해시 값을 만들 수 있는 지 보여주는 일종의 불리언 표현식을 사용해야한다.
9 changes: 4 additions & 5 deletions 20-37/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Assigned to

* 최희재/@gmlwo530
* 신정훈/@shin2jhoon
- 최희재/@gmlwo530
- 신정훈/@shin2jhoon

Mandatory reviewer

* 권용민/@snowmerak
* 이재원/@mumunuu
- 권용민/@snowmerak
- 이재원/@mumunuu

## Data Structures 20

Expand Down Expand Up @@ -57,4 +57,3 @@ Mandatory reviewer
> > #### Find key 36
> >
> > #### Map key restrictions 36
23 changes: 11 additions & 12 deletions 37-55/37-55.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ Changed User Email To [email protected]

아래 예제들은 실제 Go의 표준 라이브러리에서 사용하는 코드들이다. 이들을 공부해보면, 값에 의한 호출과 참조에 의한 호출\(pointer semantic\) 중 하나를 일관되게 사용하는 것이 얼마나 중요한지 알 수 있다. 따라서 변수의 타입을 정할 때, 다음의 질문에 스스로 답해보자.

* 이 타입은 값에 의한 호출과 참조에 의한 호출 중 어느 것이 더 적합한가?
* 만약 이 변수의 값을 변경해야 한다면, 새로운 값을 가지는 복사본을 만드는 것과, 다른 곳에서도 이 변경된 값을 확인할 수 있게 이 변수의 값을 직접 변경하는 것 중 어느 것이 더 적합한가?
- 이 타입은 값에 의한 호출과 참조에 의한 호출 중 어느 것이 더 적합한가?
- 만약 이 변수의 값을 변경해야 한다면, 새로운 값을 가지는 복사본을 만드는 것과, 다른 곳에서도 이 변경된 값을 확인할 수 있게 이 변수의 값을 직접 변경하는 것 중 어느 것이 더 적합한가?

가장 중요한 것은 일관성이다. 처음에 한 결정이 잘못되었다고 판단되면, 그때 이를 변경하면 된다.

Expand Down Expand Up @@ -462,10 +462,10 @@ p := pipe{"cfg_service"}

`iTable`은 다음의 두 가지를 제공한다:

* 첫 번째 부분은 저장된 데이터의 타입을 나타낸다. 이 예제에서는 `file` 타입을 말한다.
* 두 번째 부분은 함수 포인터의 모체로서, 인터페이스를 통해 메서드를 호출할 때 정확한 메서드를 호출하기 위하여 사용된다.
- 첫 번째 부분은 저장된 데이터의 타입을 나타낸다. 이 예제에서는 `file` 타입을 말한다.
- 두 번째 부분은 함수 포인터의 모체로서, 인터페이스를 통해 메서드를 호출할 때 정확한 메서드를 호출하기 위하여 사용된다.

![iTable for \`file\`](../.gitbook/assets/48.jpg)
![iTable for `file`](../.gitbook/assets/48.jpg)

인터페이스를 통해서 `read`를 호출하면, `iTable`을 확인해서 이 타입에 맞는 `read` 함수를 찾고 이를 호출한다. 결과적으로 구체적 타입의 `read` 메서드를 호출하는 것이다.

Expand All @@ -475,7 +475,7 @@ retrieve(f)

`p`도 이와 동일하다. `reader` 인터페이스의 첫 번째 워드는 `pipe` 타입을 가리키고, 두번째 워드는 `p`의 복사본을 가리킨다.

![iTable for \`pipe\`](../.gitbook/assets/49-1.jpg)
![iTable for `pipe`](../.gitbook/assets/49-1.jpg)

데이터가 변경되었기 때문에, 동작도 다르다.

Expand Down Expand Up @@ -575,8 +575,8 @@ u := user{"Hoanh", "[email protected]"}

다음은 그 규칙들이다.

* 주어진 타입 T의 어떤 값에 대해, 값 리시버로 구현한 메서드들만이 이 타입의 메서드 집합에 속한다.
* 주어진 타입 \*T \(타입 T의 포인터\)의 어떤 값에 대해, 값 리시버와 포인터 리시버를 사용하는 모든 메서드들이 이 타입의 메서드 집합에 속한다.
- 주어진 타입 T의 어떤 값에 대해, 값 리시버로 구현한 메서드들만이 이 타입의 메서드 집합에 속한다.
- 주어진 타입 \*T \(타입 T의 포인터\)의 어떤 값에 대해, 값 리시버와 포인터 리시버를 사용하는 모든 메서드들이 이 타입의 메서드 집합에 속한다.

즉, 어떤 타입의 포인터를 사용한다면 선언된 모든 메서드들은 모두 이 포인터를 통해 사용이 가능하다. 만약 어떤 타입의 값을 사용한다면 값에 의한 호출을 사용하는 메서드들만이 사용이 가능하다.

Expand All @@ -602,8 +602,8 @@ func (d *duration) notify() {

`42`를 받아서, 이를 `duration` 타입으로 변경 후 `notify` 메서드를 호출해보자. 이때, 컴파일러는 다음과 같은 에러 메시지를 보여준다.

* "cannot call pointer method on duration\(42\)"
* "cannot take the address of duration\(42\)"
- "cannot call pointer method on duration\(42\)"
- "cannot take the address of duration\(42\)"

```go
duration(42).notify()
Expand All @@ -619,7 +619,7 @@ duration(42).notify()

이 문제를 해결하기 위해서는, `u` 대신 `u`의 주소 값\(&u\)를 전달해야 한다. `user`의 값을 만들고 이 값의 주소 값을 전달하면, 인터페이스는 `user` 타입의 주소 값을 가지게 되고 원본 값을 가리킬 수 있게 된다.

![pointer of \`u\`](../.gitbook/assets/53.jpg)
![pointer of `u`](../.gitbook/assets/53.jpg)

```go
sendNotification(&u)
Expand Down Expand Up @@ -688,4 +688,3 @@ for _, e := range entities {
My name is Hoanh and my email is [email protected]
My name is Hoanh An and my email is [email protected]
```

7 changes: 3 additions & 4 deletions 37-55/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Assigned to

* 정영훈/@aeuveritas
- 정영훈/@aeuveritas

Mandatory reviewer

* 김지훈/@ghun2
* 최희재/@gmlwo530
- 김지훈/@ghun2
- 최희재/@gmlwo530

## Decoupling 37

Expand All @@ -24,4 +24,3 @@ Mandatory reviewer
> > #### Valueless type 46
> >
> > #### Interface via pointer receiver 50
Loading

0 comments on commit 1a7e388

Please sign in to comment.