Giter Club home page Giter Club logo

go-project-blueprint's Introduction

Blueprint/Boilerplate For Golang Projects

Build Status Maintainability Rating Test Coverage Go Report Card


If you find this useful, you can support me on Ko-Fi (Donations are always appreciated, but never required):

ko-fi

Blog Posts - More Information About This Repo

You can find more information about this project/repository and how to use it in following blog posts:

Setting Up

  • Replace All Occurrences of martinheinz/go-project-blueprint with your username repository name
  • Replace All Occurrences of blueprint with your desired image name

Adding New Libraries/Dependencies

go mod vendor

Using GitHub Registry

Create and Push:

docker login docker.pkg.github.com -u <USERNAME> -p <GITHUB_TOKEN>
docker build -t  docker.pkg.github.com/martinheinz/go-project-blueprint/blueprint:latest .
# make container
docker push docker.pkg.github.com/martinheinz/go-project-blueprint/blueprint:latest
# make push

Pull and Run:

docker pull docker.pkg.github.com/martinheinz/go-project-blueprint/blueprint:latest
docker run docker.pkg.github.com/martinheinz/go-project-blueprint/blueprint:latest

Setup new SonarCloud Project

  • On SonarCloud:
    • Click Plus Sign in Upper Right Corner
    • Analyze New Project
    • Click GitHub app configuration link
    • Configure SonarCloud
    • Select Repository and Save
    • Go Back to Analyze Project
    • Tick Newly Added Repository
    • Click Set Up
    • Click Configure with Travis
    • Copy the Command to Encrypt the Travis Token
    • Run travis encrypt --com <TOKEN_YOU_COPPIED>
    • Populate the secure Field in .travis.yml with outputted string
    • Follow steps to populate your sonar-project.properties
    • Push
  • On Travis CI:
    • Set DOCKER_USERNAME
    • Set DOCKER_PASSWORD to Your GitHub Registry Token

Setup CodeClimate

  • Go to https://codeclimate.com/github/repos/new
  • Add Repository
  • Go to Test Coverage Tab
  • Copy Test Reporter ID
  • Go to Travis and Open Settings for Your Repository
  • Add Environment Variable: name: CC_TEST_REPORTER_ID, value: Copied from CodeClimate

go-project-blueprint's People

Contributors

martinheinz avatar marvincaspar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-project-blueprint's Issues

"Problems" with makefile

Hi, whenever I try to apply make test, the following appears:

flag provided but not defined: -u
Usage of id:
  -in string
        path to NodeIds.csv (default "schema/NodeIds.csv")
  -out string
        path to generated file (default "id/id_gen.go")
flag provided but not defined: -g
Usage of id:
  -in string
        path to NodeIds.csv (default "schema/NodeIds.csv")
  -out string
        path to generated file (default "id/id_gen.go")
Running tests:
build github.com/MartinHeinz/go-project-blueprint/cmd/blueprint: cannot load github.com/alecthomas/template: open /src/vendor/github.com/alecthomas/template: no such file or directory
make: *** [test] Error 1

It seems like some command underneath is using wrong flags. (this is just a warning)
But, the process ends with failure because it is assuming the user had installed dependencies with go mod vendor. Maybe you should add that step to prevent that.

Extending the REST branch to show off a CRUD implementation

Hi!

I love your article series on the ultimate Golang project structure, and it gives a good overview on how to implement a nice structure for building api services in Golang. However, I feel like the blueprint repo lacks something to make the articles more useful, and showing off how the structure could help one create more powerful services.

An example is Services where you say one could do more filtering, but all you show is calling the Get method of the UserDAO, which makes it feel like it's not really useful. What I think would really help showing off how powerful this structure could be, is creating a full Create, Read, Update, Delete for a user api, utilising all the functionality you describe in the article.

Adding more golang tools

Any discussion is of course opinionated, but I'm typically using:

  • golangci-lint
  • goreleaser
  • and sometimes seihon (multi-arch docker builder)

viper usage

I like your blueprint. I know the purpose of the blueprint is not about config but I think there is an issue in your viper usage. Without changing anything I created an image make container OS=linux, then I tried to create a docker container but I run to the following error.

panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/bdarge/go-project-blueprint/cmd/blueprint/config.LoadConfig(0xc000161110, 0x1, 0x1, 0xcbc689, 0x2)
	/src/cmd/blueprint/config/config.go:37 +0x59f
main.main()
	/src/cmd/blueprint/main.go:39 +0x85

I guess one can do Config.DSN = v.Get("DSN").(string) only after config has read. I may be wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.