Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/lokstory/digo

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/lokstory/digo

  • v0.0.0-20190618044510-a5e231e79768
  • Source
  • Go
  • Socket score

Version published
Created
Source

GoDoc

Digo

In Taiwanese, the mean of "Digo" is "Pig Brother".

Say goodbye to "import cycle not allowed"!



Before use

Recommend putting interfaces and models in separated packages without business logic.

Wonderful package structure

Trying Clean Architecture on Golang - Iman Tumorang

Installation

go get -u github.com/lokstory/digo

Usage

Generation

It will generate below files:

  • digo package in the root path of project
  • digo.go in every packages which needs to inject dependencies
Linux
go run $GOPATH/src/github.com/lokstory/digo/main.go -path=PROJECT_ROOT_PATH
Windows
go run %GOPATH%\src\github.com\lokstory\digo\main.go -path=PROJECT_ROOT_PATH

Injecting

package main

import (
    "./digo"
)

func main() {
    // Inject dependencies
    digo.Start()
}

Annotations

@DigoSource

  • Expose variables by upper camel case
  • Keys must be unique
  • Variables' types must be declared even it can be omitted
  • Variables must be initialized before call digo.Start()
Set sources by type

The source key will be package/path/IHelloService.

    // @DigoSource
    // This generator allows to write comments between annotations and variables.
    // Annotations will be ignored if contains empty lines.
    var HelloService IHelloService = &HelloService{}
Set sources by name

The source key will be HelloService.

    // @DigoSource(HelloService)
    var HelloService IHelloService = &HelloService{}

@DigoInject

When using this annotation, it will create digo.go in the same package to inject the dependency.

Inject dependencies by type
    // @DigoInject
    var helloService IHelloService
Inject dependencies by name
    // @DigoInject(HelloService)
    var helloService IHelloService

FAQs

Package last updated on 18 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc