Go lang - 6 : 함수 3

개발조아·2022년 3월 26일
0

go-lang

목록 보기
6/13

다중 반환값

Go 에서 함수는 다중 반환값을 허용한다!
조금 생소하지만 편리해 보인다.

package main

import "fmt"

type BlogDto struct {
	Id    int
	Title string
	Owner string
}

func main() {
	dto := BlogDto{
		Id:    1,
		Title: "Phoenix",
		Owner: "개발조아",
	}
	profile, comment := BlogProfile(dto)
	fmt.Println("내 블로그 소개", profile, comment)
}

func BlogProfile(dto BlogDto) (string, string) {
	return "\nid : " + fmt.Sprint(dto.Id) + "\n제목 : " + dto.Title + "\n필자 : " + dto.Owner,
		"\n\n화이팅 합시다!"
}

Console

profile
https://github.com/askePhoenix

0개의 댓글

관련 채용 정보

Powered by GraphCDN, the GraphQL CDN