DEV Community

Cover image for Project Management Strategy in golang
Javad Rajabzadeh for Gopher

Posted on

Project Management Strategy in golang

Project Creator

create project and management with go modules

Create your project

  1. go to GOPATH in local cd $GOPATH
  2. If there is no src,bin,pkg folder, create them mkdir -p {src,bin,pkg}
  3. go to src folder cd src
  4. create your github repository
  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. create the first Go module in the project go mod init github.com/username/project
  10. You can now add modules to your project using go get ...

Project structure type

  1. Flat Structures - Basic
├── file1.go
├── file2.go
├── file3.go
├── main.go
├── LICENSE
└── README.md
Enter fullscreen mode Exit fullscreen mode
  1. Standard Structures - Good
├── _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
Enter fullscreen mode Exit fullscreen mode
  1. MVC Pattern Structures - Excellent
├── _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
Enter fullscreen mode Exit fullscreen mode

Project Contributor

  1. Create a fork of the target project in your repository
  2. Go to your $GOPATH via cd $GOPATH
  3. Create the bin,pkg,src folders if you don't already have them using mkdir -p {src,bin,pkg}.
  4. Create the target module's original path using mkdir -p src/github.com/target
  5. Change the username of the target module to the creator of the project or the organization
  6. Go to target path cd src/github.com/target
  7. Clone the forked project in the current directory by cloning git clone https://github.com/your_username/project.git
  8. Go to project folder cd project
  9. By using go get ./..., obtaining the necessary packages
  10. You should add git remote upstream https://github.com/target/project.git to update your fork.
  11. Working on your project and sending your PR
  12. Every time before you start coding, you should:
    • git fetch upstream
    • git merge upstream/main
    • git merge upstream/branch1
    • git merge upstream/branch2
    • Push any changes to your forked branch via git push origin main or git push origin branch1

Top comments (0)