Skip to content

Instantly share code, notes, and snippets.

@tenntenn
Created September 5, 2012 16:01
Show Gist options
  • Save tenntenn/3639023 to your computer and use it in GitHub Desktop.
Save tenntenn/3639023 to your computer and use it in GitHub Desktop.
student.go
package student
import "fmt"
type Student struct {
id int
name string
}
func (s *Student) Id() int {
return s.id
}
func (s *Student) Name() string {
return s.name
}
func (s *Student) String() string {
return fmt.Sprintf("%d %s",s.id, s.name)
}
func New(id int, name string) *Student {
if id <= 0 {
panic("idは1以上です。")
}
return &Student{id, name}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment