Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unexported field should be ignored #1

Merged
merged 2 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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