project-layout icon indicating copy to clipboard operation
project-layout copied to clipboard

I wrote a script to initialize the project, please check it!

Open ares0x opened this issue 4 years ago • 4 comments

`#!/bin/bash

PWD=$(pwd)
cd $PWD

if [[ "$1" = "" ]]; then
echo -ne "Please Input The Golang Porject Name: "
read project
if [ "$project" = "" ]; then
echo -e "demo";
PRO_NAME=demo;
else
PRO_NAME=$project;
fi
else
PRO_NAME=$1;
fi
#build directory
echo "Init $PRO_NAME Directory …"
mkdir -p $PRO_NAME/api
mkdir -p $PRO_NAME/assets
mkdir -p $PRO_NAME/build
mkdir -p $PRO_NAME/cmd
mkdir -p $PRO_NAME/conf
mkdir -p $PRO_NAME/deployments
mkdir -p $PRO_NAME/docs
mkdir -p $PRO_NAME/examples
mkdir -p $PRO_NAME/githooks
mkdir -p $PRO_NAME/init
mkdir -p $PRO_NAME/internal
mkdir -p $PRO_NAME/pkg
mkdir -p $PRO_NAME/scripts
mkdir -p $PRO_NAME/test
mkdir -p $PRO_NAME/third_patry
mkdir -p $PRO_NAME/tools
mkdir -p $PRO_NAME/vendor
mkdir -p $PRO_NAME/web
mkdir -p $PRO_NAME/website
cd $PRO_NAME
touch .gitkeep
go mod init $PRO_NAME

echo "Generate main.go "
cd cmd
echo "package main" > main.go
echo >> main.go
echo "import (" >> main.go
echo " \"fmt\"" >> main.go
echo ")" >> main.go
echo >> main.go
echo "func main() {" >> main.go
echo " fmt.Println(\"Hello $PRO_NAME!\")" >> main.go
echo "}" >> main.go
gofmt main.go
echo "Init $PRO_NAME Success!"`

ares0x avatar Aug 20 '20 06:08 ares0x

Please wrap the code into three backticks (`)

tsatke avatar Oct 02 '20 13:10 tsatke

I'd consider adding empty .gitkeep files in all directories.

tsatke avatar Oct 02 '20 13:10 tsatke

I'd consider adding empty .gitkeep files in all directories. Okay.I modified it.And if you want check it agin,come here, please.

ares0x avatar Oct 30 '20 03:10 ares0x

A golang project structure in shell script. Check mine out its in go and fixes all the issues with this. https://github.com/complexorganizations/gocreate

ghost avatar Jan 17 '21 03:01 ghost