From e9f8c5853810773b009485ba37deb341f394740f Mon Sep 17 00:00:00 2001 From: sarulabs Date: Tue, 26 Aug 2025 22:38:06 +0200 Subject: [PATCH 1/3] Update logo --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8b4316..9e8b939 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -![DINGO](https://raw.githubusercontent.com/sarulabs/assets/master/dingo/logo.png) +

+ +

Generation of dependency injection containers for go programs (golang). From ed40e69da3d3b711ccc209fccb19d3fa2ef99fe9 Mon Sep 17 00:00:00 2001 From: sarulabs Date: Tue, 26 Aug 2025 22:45:12 +0200 Subject: [PATCH 2/3] Remove travis and use github workflow --- .github/workflows/workflow.yml | 56 ++++++++++++++++++++++++++++++++++ .travis.yml | 6 ---- README.md | 7 ++--- 3 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/workflow.yml delete mode 100644 .travis.yml 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 9e8b939..8a43b06 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,9 @@ The disadvantage is that the code must be generated. But this can be compensated # Table of contents -[![Build Status](https://travis-ci.org/sarulabs/dingo.svg?branch=master)](https://travis-ci.org/sarulabs/dingo) -[![GoDoc](https://godoc.org/github.com/sarulabs/dingo?status.svg)](http://godoc.org/github.com/sarulabs/dingo) -[![codebeat badge](https://codebeat.co/badges/833d6016-e4dd-482f-bcfe-210a1be48b94)](https://codebeat.co/projects/github-com-sarulabs-dingo-master) -[![goreport](https://goreportcard.com/badge/github.com/sarulabs/dingo)](https://goreportcard.com/report/github.com/sarulabs/dingo) +[![Go Reference](https://pkg.go.dev/badge/github.com/sarulabs/dingo.svg)](https://pkg.go.dev/github.com/sarulabs/dingo) +![Go version](https://img.shields.io/badge/version-%3E%3D%201.16-007d9c?logo=go&logoColor=white&style=flat-square) +![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/sarulabs/dingo/workflow.yml?style=flat-square) - [Dependencies](#dependencies) - [Similarities with di](#similarities-with-di) From 9170d58e15d8797d319d1a199d7fb70c7eba1488 Mon Sep 17 00:00:00 2001 From: sarulabs Date: Tue, 26 Aug 2025 23:12:38 +0200 Subject: [PATCH 3/3] Fix code go pass staticcheck --- generation.go | 2 +- paramScanner.go | 2 +- scan.go | 2 +- scanner.go | 12 ++++++------ typeManager.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) 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") }