Go언어 문법 예시

VDoring·2021년 9월 2일
0

Golang 스터디

목록 보기
2/5

if a {
	// 실행내용
}

if a := 0; a {
	// 실행 내용
}

func f() {
	defer fmt.Println("Printed \"Hello World\" is Done.")
	fmt.Println("Hello World!")
}

출력결과
Hello World!
Printed "Hello World" is Done.

switch value {
	case 1, 2, 3:
		fmt.Println("1, 2, 3")
	case 10 <= value && value <= 100:
		fmt.Println("10 ~ 100")
		fallthrough
	default:
		fmt.Println("Switch is done.")
}

for i := 0; i < 100; i++ {
	fmt.Println(i)
}

for i, v := range []int{1, 2, 3} {
	fmt.Println(i, v)
}

for {
	fmt.Println("print")
}

func f() (int, int, int) {
	return 1, 2, 3
}

func f(a, b, c int)

func f(data ...int) 가변인자

typedef struct Apple { -> C언어 구조체 예시
	unsigned price = 0;
}

type Apple struct {
	price uint
}

func (apple Apple) Init() *Apple {
	return &Apple{
		price: 0,
	}
}

a map[string]string = map[string]string{
	"Apple": "apple",
	"Banana", "banana",
}
profile
< Beginners Heart >

0개의 댓글