Skip to content

Commit

Permalink
Fix a bunch of lint warnings in testprograms/interfaces.
Browse files Browse the repository at this point in the history
Not all have been fixed, these remain:

testprograms/interfaces/lib/lib.go:24:6: type name will be used as lib.LibA by other packages, and that stutters; consider calling this A
testprograms/interfaces/lib/lib.go:31:6: type name will be used as lib.LibC by other packages, and that stutters; consider calling this C
testprograms/interfaces/lib/lib.go:34:6: type name will be used as lib.LibAB by other packages, and that stutters; consider calling this AB

But I don't want to call them that, because I want separate names from
those in package main.
  • Loading branch information
korfuri committed Jul 16, 2017
1 parent 900c88f commit 4464f38
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
30 changes: 27 additions & 3 deletions testprograms/interfaces/lib/lib.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
// Package lib contains interfaces and types that implement them. It
// is very similar to package main, whose interfaces its types also
// implements.
package lib

// IfaceLibA is a simple test interface.
type IfaceLibA interface {
A()
}

// IfaceLibB is a simple test interface.
type IfaceLibB interface {
B()
}

// IfaceLibAB is a simple test interface that extends IfaceLibA and
// IfaceLibB.
type IfaceLibAB interface {
A()
B()
}

// LibA implements IfaceLibA
type LibA int

// libB implements IfaceLibB, and is unexported
type libB int

// LibC doesn't implement anything from this package but implements
// the unexported main.ifaceC.
type LibC int

// LibAB implements IfaceLibAB
type LibAB int

func (a LibA) A() {}
func (b libB) B() {}
func (c LibC) C() {}
// A implements IfaceLibA
func (a LibA) A() {}

// B implements IfaceLibB
func (b libB) B() {}

// C is just a member functions of LibC
func (c LibC) C() {}

// A implements IfaceLibA
func (ab LibAB) A() {}

// B implements IfaceLibB
func (ab LibAB) B() {}
27 changes: 25 additions & 2 deletions testprograms/interfaces/main.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,65 @@
// Package main is a test program that demonstrates
// interface-implementation relations in goref.
package main

import (
"github.com/korfuri/goref/testprograms/interfaces/lib"
)

// use is a function to avoid "unused variable" errors
func use(interface{}) {}

func main() {
use(lib.LibA(0))
acceptAB(AB(0))
}

// IfaceA is a simple interface
type IfaceA interface {
A()
}

// IfaceB is a simple interface
type IfaceB interface {
B()
}

// IfaceAB is a simple interface that extends IfaceA and IfaceB.
type IfaceAB interface {
A()
B()
}

// ifaceC is an unexported interface.
type ifaceC interface {
C()
}

// Empty is an empty interface.
type Empty interface{}

// A A implements IfaceA.
// ^ golint doesn't differentiate between the leading article and the
// type name.
type A int

// B implements IfaceB.
type B int

// AB implements IfaceAB, IfaceA and IfaceB.
type AB int

func (a A) A() {}
func (b B) B() {}
// A implements IfaceA.
func (a A) A() {}

// B implements IfaceB.
func (b B) B() {}

// A implements IfaceA.
func (ab AB) A() {}

// B implements IfaceB.
func (ab AB) B() {}

// acceptAB tests for acceptance of IfaceAB.
func acceptAB(IfaceAB) {}

0 comments on commit 4464f38

Please sign in to comment.