Go 1.24에서 제네릭 제약을 다음처럼 쓰려고 했는데 컴파일이 안 됩니다.
type Identified interface {
~struct{ ID int }
}
func GetID[T Identified](v T) int { return v.ID }
에러는 interface contains type constraints with struct types. 기본형 제약(~int)은 잘 되는데 struct는 왜 안 되는 거죠?
Go 1.24에서 제네릭 제약을 다음처럼 쓰려고 했는데 컴파일이 안 됩니다.
type Identified interface {
~struct{ ID int }
}
func GetID[T Identified](v T) int { return v.ID }
에러는 interface contains type constraints with struct types. 기본형 제약(~int)은 잘 되는데 struct는 왜 안 되는 거죠?
댓글 0