- Move geometry package from _demo to cl/_testdata/geometry1370 - Create simplified test in cl/_testgo/interface1370 following interface test pattern - Generate .ll file with llgen to verify interface metadata package path fix - Remove old demo files (issue1370_geometry, issue1370_goast, issue1370_gotypes) - Remove .tmp-comment files The new test structure is simpler and follows the existing cl/_testgo/interface pattern, focusing on demonstrating the interface metadata fix for private methods across packages. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
26 lines
565 B
Go
26 lines
565 B
Go
package geometry1370
|
|
|
|
type Shape interface {
|
|
Area() float64
|
|
validate() bool
|
|
setID(int)
|
|
}
|
|
|
|
type Rectangle struct {
|
|
Width, Height float64
|
|
id int
|
|
}
|
|
|
|
func (r *Rectangle) Area() float64 { return r.Width * r.Height }
|
|
func (r *Rectangle) validate() bool { return r.Width > 0 && r.Height > 0 }
|
|
func (r *Rectangle) setID(id int) { r.id = id }
|
|
func (r *Rectangle) GetID() int { return r.id }
|
|
|
|
func NewRectangle(width, height float64) *Rectangle {
|
|
return &Rectangle{Width: width, Height: height}
|
|
}
|
|
|
|
func RegisterShape(s Shape, id int) {
|
|
s.setID(id)
|
|
}
|