Skip to content
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
56 changes: 56 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
![DINGO](https://raw.githubusercontent.com/sarulabs/assets/master/dingo/logo.png)
<p align="center">
<img src="https://raw.githubusercontent.com/sarulabs/assets/master/dingo/logo_2025.png" width="250" />
</p>

Generation of dependency injection containers for go programs (golang).

Expand All @@ -13,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)
Expand Down
2 changes: 1 addition & 1 deletion generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion paramScanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) + ": "
Expand Down
12 changes: 6 additions & 6 deletions scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions typeManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
}
Expand Down