Skip to content

Instantly share code, notes, and snippets.

@Ja7ad
Last active April 7, 2021 07:07
Show Gist options
  • Save Ja7ad/fb4511f01957cd13bba3b46618e7eb2b to your computer and use it in GitHub Desktop.
Save Ja7ad/fb4511f01957cd13bba3b46618e7eb2b to your computer and use it in GitHub Desktop.
Go Project Management Strategy

Project Creator

create project and management with go modules

Intitial your project

  1. go to GOPATH in local cd $GOPATH
  2. if not having src,bin,pkg folder , create they mkdir -p {src,bin,pkg}
  3. go to src folder cd src
  4. create repository your project in github
  5. create folder mkdir -p github.com/username
    • change username to your username
  6. go to folder github.com/username via cd github.com/username
  7. clone project from github git clone https://github.com/username/project.git
  8. go to project folder cd project
  9. initial go module in project go mod init github.com/username/project
  10. now you work with your project and you can add modules via go get ...

Type project structures

  1. Flat Structures
├── file1.go
├── file2.go
├── file3.go
├── main.go
├── LICENSE
└── README.md
  1. Standard Structures
├── _example # this is dir for your examples
│   ├── sample1
│       ├── sample1.go
│       └── sample1_test.go
│   └── sample2
│       ├── sample2.go
│       └── sample2_test.go
├── dir1
│   ├── file1.go
│   └── file1_test.go
├── dir2
│   ├── file2.go
│   └── file2_test.go
├── dir3
│   ├── file3.go
│   ├── file3_test.go
│   ├── file4.go
│   ├── file4_test.go
│   └── file5.go
├── dir4
│   ├── samplefolder
│       ├── file6.go
│       └── file6_test.go
├── LICENSE
├── go.mod
├── go.sum
├── main.go or project.go # project.go for pkg project
└── README.md
  1. MVC Pattern Structures
├── _example # this is dir for your examples
│   ├── sample1
│       ├── sample1.go
│       └── sample1_test.go
│   └── sample2
│       ├── sample2.go
│       └── sample2_test.go
├── module
│   ├── file1.go
│   ├── file1_test.go
│   └── samplefolder
│       ├── file6.go
│       └── file6_test.go
├── view
│   ├── file2.go
│   └── file2_test.go
├── controller
│   ├── file3.go
│   ├── file3_test.go
│   ├── file4.go
│   ├── file4_test.go
│   └── file5.go
├── LICENSE
├── go.mod
├── go.sum
├── main.go
└── README.md

Project Contributer

  1. Fork target project to your repository
  2. Go to your $GOPATH via cd $GOPATH
  3. If your not having bin,pkg,src folder creating using mkdir -p {src,bin,pkg}
  4. Create target module original path mkdir -p src/github.com/target
    • change target to username project creator or organization
  5. Go to target path cd src/github.com/target
  6. Clone Forked Project in current path git clone https://github.com/your_username/project.git
  7. Go to project folder cd project
  8. Getting required packages via go get ./...
  9. Add remote git remote add upstream https://github.com/target/project.git to update your fork repo.
  10. Working on Project and send yours PR
  11. Before start coding every times do
    • git fetch upstream
    • git merge upstream/main
    • git merge upstream/branch1
    • git merge upstream/branch2
    • If any file changed via merge, push on your forked branch via git push origin main or git push origin branch1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment