structs.go 658 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package structs
  5. type S struct {
  6. X, Y float64
  7. unexported bool
  8. }
  9. func (s *S) Sum() float64 {
  10. return s.X + s.Y
  11. }
  12. func (s *S) Identity() (*S, error) {
  13. return s, nil
  14. }
  15. func Identity(s *S) *S {
  16. return s
  17. }
  18. func IdentityWithError(s *S) (*S, error) {
  19. return s, nil
  20. }
  21. type (
  22. S2 struct{}
  23. I interface {
  24. M()
  25. }
  26. )
  27. func (s *S2) M() {
  28. }
  29. func (_ *S2) String() string {
  30. return ""
  31. }
  32. // Structs is a struct with the same name as its package.
  33. type Structs struct{}
  34. func (_ *Structs) M() {
  35. }