Go 구조체간 형 변환

1 개요[ | ]

Go struct 형 변환
Go struct간 형 변환
Go 구조체 형 변환
Go 구조체간 형 변환
package main

import "fmt"

type Foo struct {
	x int
	y int
}
type Bar struct {
	x int
	y int
}

func main() {
	a := Foo{}
	fmt.Printf("%#v\n", a)      // main.Foo{x:0, y:0}
	fmt.Printf("%#v\n", Bar(a)) // main.Bar{x:0, y:0}

	b := Foo{x: 100, y: 200}
	fmt.Printf("%#v\n", b)      // main.Foo{x:100, y:200}
	fmt.Printf("%#v\n", Bar(b)) // main.Bar{x:100, y:200}
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}