Skip to content

Commit 1d1c3c8

Browse files
committed
Feat: change the project structure
Signed-off-by: barnettZQG <[email protected]>
1 parent f23751c commit 1d1c3c8

File tree

10 files changed

+73
-49
lines changed

10 files changed

+73
-49
lines changed

.github/workflows/go-test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- v*
8+
workflow_dispatch: { }
9+
pull_request:
10+
branches:
11+
- master
12+
13+
jobs:
14+
tests:
15+
runs-on: "ubuntu-20.04"
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-go@v3
19+
with:
20+
go-version: '1.17'
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v3
23+
with:
24+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
25+
version: v1.29
26+
- run: go test -cpu=2 -race -v ./...
27+
- run: go test -cpu=2 -covermode=atomic ./...
28+

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

common_test.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

example_test.go renamed to example/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
"os"
77

8-
"github.com/facebookgo/inject"
8+
"github.com/barnettZQG/inject"
99
)
1010

1111
// Our Awesome Application renders a message using two APIs in our fake

go.mod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module github.com/barnettZQG/inject
2+
3+
go 1.17
4+
5+
require (
6+
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c
7+
github.com/facebookgo/structtag v0.0.0-20150214074306-217e25fb9691
8+
)
9+
10+
require (
11+
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
13+
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
14+
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
4+
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
5+
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
6+
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
7+
github.com/facebookgo/structtag v0.0.0-20150214074306-217e25fb9691 h1:KnnwHN59Jxec0htA2pe/i0/WI9vxXLQifdhBrP3lqcQ=
8+
github.com/facebookgo/structtag v0.0.0-20150214074306-217e25fb9691/go.mod h1:sKLL1iua/0etWfo/nPCmyz+v2XDMXy+Ho53W7RAuZNY=
9+
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
10+
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=

inject_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/barnettZQG/inject"
1011
"github.com/facebookgo/ensure"
11-
"github.com/facebookgo/inject"
1212

13-
injecttesta "github.com/facebookgo/inject/injecttesta"
14-
injecttestb "github.com/facebookgo/inject/injecttestb"
13+
injecttesta "github.com/barnettZQG/inject/test/injecttesta"
14+
injecttestb "github.com/barnettZQG/inject/test/injecttestb"
1515
)
1616

1717
func init() {
@@ -24,7 +24,8 @@ type Answerable interface {
2424
}
2525

2626
type TypeAnswerStruct struct {
27-
answer int
27+
answer int
28+
//nolint
2829
private int
2930
}
3031

@@ -156,6 +157,7 @@ func TestPrivate(t *testing.T) {
156157
}
157158

158159
type TypeWithJustColon struct {
160+
//nolint:govet
159161
A *TypeAnswerStruct `inject:`
160162
}
161163

@@ -168,11 +170,13 @@ func TestTagWithJustColon(t *testing.T) {
168170

169171
const msg = "unexpected tag format `inject:` for field A in type *inject_test.TypeWithJustColon"
170172
if err.Error() != msg {
171-
t.Fatalf("expected:\n%s\nactual:\n%s", msg, err.Error())
173+
var a TypeWithJustColon
174+
t.Fatalf("expected:\n%s\nactual:\n%s %v", msg, err.Error(), a.A)
172175
}
173176
}
174177

175178
type TypeWithOpenQuote struct {
179+
//nolint:govet
176180
A *TypeAnswerStruct `inject:"`
177181
}
178182

@@ -185,7 +189,7 @@ func TestTagWithOpenQuote(t *testing.T) {
185189

186190
const msg = "unexpected tag format `inject:\"` for field A in type *inject_test.TypeWithOpenQuote"
187191
if err.Error() != msg {
188-
t.Fatalf("expected:\n%s\nactual:\n%s", msg, err.Error())
192+
t.Fatalf("expected:\n%s\nactual:\n%s %v", msg, err.Error(), a.A)
189193
}
190194
}
191195

@@ -238,7 +242,7 @@ func TestProvideTwoOfTheSame(t *testing.T) {
238242
t.Fatal("expected error")
239243
}
240244

241-
const msg = "provided two unnamed instances of type *github.com/facebookgo/inject_test.TypeAnswerStruct"
245+
const msg = "provided two unnamed instances of type *github.com/barnettZQG/inject_test.TypeAnswerStruct"
242246
if err.Error() != msg {
243247
t.Fatalf("expected:\n%s\nactual:\n%s", msg, err.Error())
244248
}
@@ -251,7 +255,7 @@ func TestProvideTwoOfTheSameWithPopulate(t *testing.T) {
251255
t.Fatal("expected error")
252256
}
253257

254-
const msg = "provided two unnamed instances of type *github.com/facebookgo/inject_test.TypeAnswerStruct"
258+
const msg = "provided two unnamed instances of type *github.com/barnettZQG/inject_test.TypeAnswerStruct"
255259
if err.Error() != msg {
256260
t.Fatalf("expected:\n%s\nactual:\n%s", msg, err.Error())
257261
}
@@ -465,10 +469,6 @@ func TestInjectOnPrivateField(t *testing.T) {
465469
}
466470
}
467471

468-
type TypeWithInjectOnPrivateInterfaceField struct {
469-
a Answerable `inject:""`
470-
}
471-
472472
func TestInjectOnPrivateInterfaceField(t *testing.T) {
473473
var a TypeWithInjectOnPrivateField
474474
err := inject.Populate(&a)
@@ -478,7 +478,7 @@ func TestInjectOnPrivateInterfaceField(t *testing.T) {
478478

479479
const msg = "inject requested on unexported field a in type *inject_test.TypeWithInjectOnPrivateField"
480480
if err.Error() != msg {
481-
t.Fatalf("expected:\n%s\nactual:\n%s", msg, err.Error())
481+
t.Fatalf("expected:\n%s\nactual:\n%s %v", msg, err.Error(), a.a)
482482
}
483483
}
484484

@@ -561,7 +561,7 @@ func TestInjectNamedOnPrivateInterfaceField(t *testing.T) {
561561

562562
const msg = "inject requested on unexported field a in type *inject_test.TypeWithInjectNamedOnPrivateInterfaceField"
563563
if err.Error() != msg {
564-
t.Fatalf("expected:\n%s\nactual:\n%s", msg, err.Error())
564+
t.Fatalf("expected:\n%s\nactual:\n%s %v", msg, err.Error(), v.a)
565565
}
566566
}
567567

readme.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
inject [![Build Status](https://secure.travis-ci.org/facebookgo/inject.png)](https://travis-ci.org/facebookgo/inject)
2-
======
1+
# Inject
32

4-
Documentation: https://godoc.org/github.com/facebookgo/inject
3+
This package provides the dependency injection with Go.
4+
5+
## Example
6+
7+
Please refer to [example](./example/)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)