반업주부의 일상 배움사
[Golang] echo 샘플2 본문
한 줄 받는 샘플.
2022.05.15 - [IT 인터넷/Golang] - [Golang] echo 샘플
[Golang] echo 샘플
문자열을 입력하면 그대로 출력하는 예제에요. stdin.ReadString 은 주어진 delimeter 까지의 문자열을 돌려줘요. package main import ( "bufio" "fmt" "os" ) func main() { stdin := bufio.NewReader(os.Stdin)..
banjubu.tistory.com
여러 줄을 받아볼께요.
엔터만 치면 빠져나가요.
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
sc := bufio.NewScanner(os.Stdin)
for sc.Scan() {
txt := sc.Text()
fmt.Println(txt)
if txt == "" {
fmt.Println("End")
break
}
}
}
결과.
$ go run main.go
Banjubu
Banjubu
Golang
Golang
End
영어, 중국어 공부중이신가요?
홈스쿨 교재. 한 권으로 가족 모두 할 수 있어요!
한GLO 미네르바에듀 : 네이버쇼핑 스마트스토어
한글로 영어가 된다?! 한글로[한GLO]는 영어 중국어 일어 러시아어 스페인어가 됩니다!!
smartstore.naver.com
반응형
LIST
'IT 인터넷 > Golang' 카테고리의 다른 글
[Golang] Gin + MySQL (0) | 2022.05.16 |
---|---|
[Golang] Hello Gin (0) | 2022.05.16 |
[Golang] echo 샘플 (0) | 2022.05.15 |
[Golang] 텍스트 파일 읽고 랜덤 아이템 추출하기 (0) | 2022.04.29 |
[Golang] 웹사이트 헬스 체크 :: Website Health Check (0) | 2021.05.05 |