Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Commit 18478f3

Browse files
committed
Use KError v0.1.1, KDone v0.2.0 and KInit v0.2.1, private naming fixes
1 parent 3e508c4 commit 18478f3

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/go-kata/kinitx
33
go 1.14
44

55
require (
6-
github.com/go-kata/kdone v0.1.1
7-
github.com/go-kata/kerror v0.1.0
8-
github.com/go-kata/kinit v0.2.0
6+
github.com/go-kata/kdone v0.2.0
7+
github.com/go-kata/kerror v0.1.1
8+
github.com/go-kata/kinit v0.2.1
99
)

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ github.com/go-kata/kdone v0.1.0 h1:TbIIVxI+q9d8JnjqCwa014bi60zZ1ILKQuk/CIGKzO0=
22
github.com/go-kata/kdone v0.1.0/go.mod h1:qNvglTe9URXMYw4vlciLBDU2FLzAqYCoROpxvx8jDwM=
33
github.com/go-kata/kdone v0.1.1 h1:GAZlb/vjlQpAn+TtKZez2eZmw/AUpRx94h/Y3A3WLJU=
44
github.com/go-kata/kdone v0.1.1/go.mod h1:qNvglTe9URXMYw4vlciLBDU2FLzAqYCoROpxvx8jDwM=
5+
github.com/go-kata/kdone v0.2.0 h1:ZaCFPwSxthYDfYj1D3r+8fW9iXq8FGt3HT/et+jyauo=
6+
github.com/go-kata/kdone v0.2.0/go.mod h1:epIfwQvmfhpg7op8E86DZxXOIuz0ZhIHN0kG9r4ye50=
57
github.com/go-kata/kerror v0.1.0 h1:Y7y0XGOrhWMU1YxvMAYw5VAeDfo4wUZrhLdSQ+KM7LE=
68
github.com/go-kata/kerror v0.1.0/go.mod h1:TtwtjetJ75COpTfrJBL9y2q4MEbDWt1r/FeF5M+5xlw=
9+
github.com/go-kata/kerror v0.1.1 h1:9RMFNpTzN0HxOZHI2Fm0FBRgx2i+0UkQzIMVvyO33Vs=
10+
github.com/go-kata/kerror v0.1.1/go.mod h1:TtwtjetJ75COpTfrJBL9y2q4MEbDWt1r/FeF5M+5xlw=
711
github.com/go-kata/kinit v0.1.0 h1:sopJkxSkuXBtxBemIavqw/qlajBpz77xSUrrfWo0Lx8=
812
github.com/go-kata/kinit v0.1.0/go.mod h1:ErsGPU8fCxUFM+uvlqtcjo0VGj7xXosLyHbmb+yYero=
913
github.com/go-kata/kinit v0.2.0 h1:rI5w2KCdnTFK7hJ9Is6zBI5b4QS7RvihtX8oCexPyG8=
1014
github.com/go-kata/kinit v0.2.0/go.mod h1:EdagOVrXQtJXZmAkIceRVhKq/jgscLua6GNzVAlpth0=
15+
github.com/go-kata/kinit v0.2.1 h1:8YvYoTHphqrs3VH4CQ4pjkAjsc6pPKB/QKWevDkngX0=
16+
github.com/go-kata/kinit v0.2.1/go.mod h1:/WhSVUU9G4gIemg7Yh7dApBFu768MB501io9xWegnbs=

kinitx.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var executorType = reflect.TypeOf((*kinit.Executor)(nil)).Elem()
3333
//
3434
// All other variants of x are unacceptable.
3535
func Provide(x interface{}) error {
36-
ctor, err := chooseConstructor(x)
36+
ctor, err := newProperConstructor(x)
3737
if err != nil {
3838
return err
3939
}

choice.go renamed to proper.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"github.com/go-kata/kinit"
88
)
99

10-
// chooseConstructor returns a new constructor based on the given entity.
10+
// newProperConstructor returns a new constructor based on the given entity.
1111
//
1212
// See the documentation for the Provide to find out possible values of the argument x.
13-
func chooseConstructor(x interface{}) (kinit.Constructor, error) {
13+
func newProperConstructor(x interface{}) (kinit.Constructor, error) {
1414
if x == nil {
1515
return nil, kerror.New(kerror.ERuntime, "function, struct or struct pointer expected, nil given")
1616
}

choice_test.go renamed to proper_test.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ func (*testCloser) Close() error {
1313
return nil
1414
}
1515

16-
func TestChooseConstructorWithConstructor(t *testing.T) {
17-
ctor, err := chooseConstructor(func() int { return 0 })
16+
func TestNewProperConstructorWithConstructor(t *testing.T) {
17+
ctor, err := newProperConstructor(func() int { return 0 })
1818
if err != nil {
1919
t.Logf("%+v", err)
2020
t.Fail()
@@ -26,8 +26,8 @@ func TestChooseConstructorWithConstructor(t *testing.T) {
2626
}
2727
}
2828

29-
func TestChooseConstructorWithOpener(t *testing.T) {
30-
ctor, err := chooseConstructor(func() *testCloser { return &testCloser{} })
29+
func TestNewProperConstructorWithOpener(t *testing.T) {
30+
ctor, err := newProperConstructor(func() *testCloser { return &testCloser{} })
3131
if err != nil {
3232
t.Logf("%+v", err)
3333
t.Fail()
@@ -39,8 +39,8 @@ func TestChooseConstructorWithOpener(t *testing.T) {
3939
}
4040
}
4141

42-
func TestChooseConstructorWithConstructorOfCloser(t *testing.T) {
43-
ctor, err := chooseConstructor(func() (*testCloser, kdone.Destructor, error) {
42+
func TestNewProperConstructorWithConstructorOfCloser(t *testing.T) {
43+
ctor, err := newProperConstructor(func() (*testCloser, kdone.Destructor, error) {
4444
return &testCloser{}, kdone.Noop, nil
4545
})
4646
if err != nil {
@@ -54,8 +54,8 @@ func TestChooseConstructorWithConstructorOfCloser(t *testing.T) {
5454
}
5555
}
5656

57-
func TestChooseConstructorWithStruct(t *testing.T) {
58-
ctor, err := chooseConstructor(testCloser{})
57+
func TestNewProperConstructorWithStruct(t *testing.T) {
58+
ctor, err := newProperConstructor(testCloser{})
5959
if err != nil {
6060
t.Logf("%+v", err)
6161
t.Fail()
@@ -67,8 +67,8 @@ func TestChooseConstructorWithStruct(t *testing.T) {
6767
}
6868
}
6969

70-
func TestChooseConstructorWithStructPointer(t *testing.T) {
71-
ctor, err := chooseConstructor((*testCloser)(nil))
70+
func TestNewProperConstructorWithStructPointer(t *testing.T) {
71+
ctor, err := newProperConstructor((*testCloser)(nil))
7272
if err != nil {
7373
t.Logf("%+v", err)
7474
t.Fail()
@@ -80,26 +80,26 @@ func TestChooseConstructorWithStructPointer(t *testing.T) {
8080
}
8181
}
8282

83-
func TestChooseConstructorWithWrongX(t *testing.T) {
84-
_, err := chooseConstructor(0)
83+
func TestNewProperConstructorWithWrongX(t *testing.T) {
84+
_, err := newProperConstructor(0)
8585
t.Logf("%+v", err)
8686
if kerror.ClassOf(err) != kerror.ERuntime {
8787
t.Fail()
8888
return
8989
}
9090
}
9191

92-
func TestChooseConstructorWithWrongFunc(t *testing.T) {
93-
_, err := chooseConstructor(func() {})
92+
func TestNewProperConstructorWithWrongFunc(t *testing.T) {
93+
_, err := newProperConstructor(func() {})
9494
t.Logf("%+v", err)
9595
if kerror.ClassOf(err) != kerror.ERuntime {
9696
t.Fail()
9797
return
9898
}
9999
}
100100

101-
func TestChooseConstructorWithWrongPointer(t *testing.T) {
102-
_, err := chooseConstructor((*int)(nil))
101+
func TestNewProperConstructorWithWrongPointer(t *testing.T) {
102+
_, err := newProperConstructor((*int)(nil))
103103
t.Logf("%+v", err)
104104
if kerror.ClassOf(err) != kerror.ERuntime {
105105
t.Fail()

0 commit comments

Comments
 (0)