Skip to content

Instantly share code, notes, and snippets.

@shubhamoli
Last active March 9, 2020 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shubhamoli/1fc1291d16eb9e1d7a6429b11d1676f1 to your computer and use it in GitHub Desktop.
Save shubhamoli/1fc1291d16eb9e1d7a6429b11d1676f1 to your computer and use it in GitHub Desktop.
Bootstrap Directory Structure for fresh GoLang project
#!/bin/sh
# Go project bootstrap file
# It creates required directory structure and files
#
# Author: Shubham Oli <oli.shubham@gmail.com>
# Date: 09-03-2020
# Inspired by: https://github.com/golang-standards/project-layout
# Name of project to be bootstrapped
NAME=$1
# Let's begin
mkdir -p $NAME/src
cd $NAME/src
touch LICENSE.md
touch README
touch .gitignore
touch Dockerfile
touch Makefile
# This is where main.go will reside
mkdir -p cmd/$NAME
touch cmd/$NAME/main.go
# Packages which we don't want to expose
mkdir -p internal/{config}
touch internal/config/config.go
# Directory for packages which we want to expose
mkdir -p pkg
# Directory where systemd scripts, etc will be kept
mkdir -p init
touch init/$NAME.service
# where test config and test data will reside
mkdir -p tests
# where helm and kubernetes related ymls will be kept
mkdir -p deployments/{helm,k8s}
@shubhamoli
Copy link
Author

shubhamoli commented Mar 9, 2020

Generated tree

$ tree hello-world/
hello-world
├── cmd
│   └── hello-world
│       └── main.go
├── deployments
│   ├── helm
│   └── k8s
├── init
│   └── hello-world.service
├── internal
│   ├── config
│   │   └── config.go
├── pkg
└── tests
├── Dockerfile
├── LICENSE.md
├── Makefile
├── README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment