diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml
new file mode 100644
index 0000000..0fced7b
--- /dev/null
+++ b/.github/workflows/workflow.yml
@@ -0,0 +1,56 @@
+name: Workflow
+
+on:
+ push:
+ branches: [ "**" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Set up Go
+ uses: actions/setup-go@v3
+ with:
+ go-version: 1
+
+ - name: Verify dependencies
+ run: go mod verify
+
+ - name: Build
+ run: go build -v ./...
+
+ - name: Run go vet
+ run: go vet . ./templates
+
+ - name: Install staticcheck
+ run: go install honnef.co/go/tools/cmd/staticcheck@latest
+
+ - name: Run staticcheck
+ run: staticcheck . ./templates
+
+ - name: Install golint
+ run: go install golang.org/x/lint/golint@latest
+
+ - name: Run golint
+ run: golint . ./templates
+
+ - name: Run tests
+ run: ./tests/run_tests.sh
+
+ build_old:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Set up Go
+ uses: actions/setup-go@v3
+ with:
+ go-version: 1.16
+
+ - name: Run tests
+ run: ./tests/run_tests.sh
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index f3e42d6..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-language: go
-
-go:
- - tip
-
-script: ./tests/run_tests.sh
diff --git a/README.md b/README.md
index b8b4316..8a43b06 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-
+
+
+
Generation of dependency injection containers for go programs (golang).
@@ -13,10 +15,9 @@ The disadvantage is that the code must be generated. But this can be compensated
# Table of contents
-[](https://travis-ci.org/sarulabs/dingo)
-[](http://godoc.org/github.com/sarulabs/dingo)
-[](https://codebeat.co/projects/github-com-sarulabs-dingo-master)
-[](https://goreportcard.com/report/github.com/sarulabs/dingo)
+[](https://pkg.go.dev/github.com/sarulabs/dingo)
+
+
- [Dependencies](#dependencies)
- [Similarities with di](#similarities-with-di)
diff --git a/generation.go b/generation.go
index 522de8d..f49d0d6 100644
--- a/generation.go
+++ b/generation.go
@@ -7,7 +7,7 @@ import (
"github.com/sarulabs/dingo/v4/templates"
)
-// GenerateContainer generates a depedency injection container.
+// GenerateContainer generates a dependency injection container.
// The definitions are loaded from the Provider.
// The code is generated in the outputDirectory.
func GenerateContainer(provider Provider, outputDirectory string) error {
diff --git a/paramScanner.go b/paramScanner.go
index 633a517..403c4da 100644
--- a/paramScanner.go
+++ b/paramScanner.go
@@ -162,7 +162,7 @@ func (s *ParamScanner) setParam(param *ParamInfo, def *ScannedDef) error {
}
func (s *ParamScanner) autofill(param *ParamInfo, acceptNotFound bool) error {
- defs, _ := s.defsByType[param.TypeString]
+ defs := s.defsByType[param.TypeString]
if len(defs) == 0 && acceptNotFound {
param.UndefinedStructParam = true
return nil
diff --git a/scan.go b/scan.go
index 4dd7ea9..cda14df 100644
--- a/scan.go
+++ b/scan.go
@@ -102,7 +102,7 @@ func (def *ScannedDef) GenerateCommentParams() string {
comment := "\t\t// \tparams:\n"
for _, key := range keys {
- p, _ := def.Params[key]
+ p := def.Params[key]
k, _ := json.Marshal(key)
comment += "\t\t// \t\t- " + string(k) + ": "
diff --git a/scanner.go b/scanner.go
index 2a96b9e..6c33ea6 100644
--- a/scanner.go
+++ b/scanner.go
@@ -100,7 +100,7 @@ func (s *Scanner) scanBuild(def *Def, scannedDef *ScannedDef) error {
return s.scanBuildStruct(def, scannedDef, t)
}
- return errors.New("Build should be a function or a pointer to a structure")
+ return errors.New("the definition Build property should be a function or a pointer to a structure")
}
func (s *Scanner) scanBuildFunc(def *Def, scannedDef *ScannedDef, buildT reflect.Type) error {
@@ -132,11 +132,11 @@ func (s *Scanner) checkBuildFunc(t reflect.Type) error {
}
if t.NumOut() != 2 {
- return errors.New("Build function must have 2 output parameters")
+ return errors.New("the Build function must have 2 output parameters")
}
if !t.Out(1).Implements(reflect.TypeOf((*error)(nil)).Elem()) {
- return errors.New("Build function second output parameter should be an error")
+ return errors.New("the Build function second output parameter should be an error")
}
return nil
@@ -169,17 +169,17 @@ func (s *Scanner) scanClose(def *Def, scannedDef *ScannedDef) error {
t := reflect.TypeOf(def.Close)
if t.Kind() != reflect.Func {
- return errors.New("Close should be a function")
+ return errors.New("the definition Close property should be a function")
}
errorInterface := reflect.TypeOf((*error)(nil)).Elem()
if t.NumOut() != 1 || !t.Out(0).Implements(errorInterface) {
- return errors.New("Close should return an error")
+ return errors.New("the definition Close property should return an error")
}
if t.NumIn() != 1 {
- return errors.New("Close should have exactly one input parameter")
+ return errors.New("the definition Close property should have exactly one input parameter")
}
return s.scanCloseParameter(def, scannedDef, t)
diff --git a/typeManager.go b/typeManager.go
index 4f645aa..aba4831 100644
--- a/typeManager.go
+++ b/typeManager.go
@@ -66,7 +66,7 @@ func (tm *TypeManager) Register(t reflect.Type) (string, error) {
case reflect.Uint64:
return tm.registerBasicType(t)
case reflect.Uintptr:
- return "", errors.New("Uintptr is not supported")
+ return "", errors.New("type Uintptr is not supported")
case reflect.Float32:
return tm.registerBasicType(t)
case reflect.Float64:
@@ -94,7 +94,7 @@ func (tm *TypeManager) Register(t reflect.Type) (string, error) {
case reflect.Struct:
return tm.registerStruct(t)
case reflect.UnsafePointer:
- return "", errors.New("UnsafePointer is not supported")
+ return "", errors.New("type UnsafePointer is not supported")
default:
return "", errors.New("type is not supported")
}