Skip to content

Commit

Permalink
Merge pull request #1 from Fs02/fix-unexported-field
Browse files Browse the repository at this point in the history
fix: unexported field should be ignored
  • Loading branch information
Fs02 committed Jan 24, 2019
2 parents 64493b5 + b13ac64 commit ccac8c8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: go
go:
- "1.9.x"
- "1.10.x"
- "1.11.x"
install:
- go get -u github.com/golang/dep/cmd/dep
before_script:
Expand Down
6 changes: 6 additions & 0 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func (container Container) Connect(val interface{}, id ...string) {

for i := 0; i < rt.NumField(); i++ {
sf := rt.Field(i)

// skip unexported field
if sf.Name[0] >= 'a' && sf.Name[0] <= 'z' {
continue
}

if tval, ok := sf.Tag.Lookup(tag); ok {

if tval == "-" {
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/Fs02/wire

require (
github.com/davecgh/go-spew v1.1.0
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.2.2
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
1 change: 1 addition & 0 deletions wire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Valuer interface {
type ComponentA struct {
Value1 string
Value2 int
value3 interface{} // unexported
}

func (c ComponentA) Value() string {
Expand Down

0 comments on commit ccac8c8

Please sign in to comment.