create project and management with go modules
- go to GOPATH in local
cd $GOPATH
- if not having src,bin,pkg folder , create they
mkdir -p {src,bin,pkg}
- go to src folder
cd src
- create repository your project in github
- create folder
mkdir -p github.com/username
- change username to your username
- go to folder github.com/username via
cd github.com/username
- clone project from github
git clone https://github.com/username/project.git
- go to project folder
cd project
- initial go module in project
go mod init github.com/username/project
- now you work with your project and you can add modules via
go get ...
- Flat Structures
├── file1.go
├── file2.go
├── file3.go
├── main.go
├── LICENSE
└── README.md
- 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
- 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
- Fork target project to your repository
- Go to your $GOPATH via
cd $GOPATH
- If your not having bin,pkg,src folder creating using
mkdir -p {src,bin,pkg}
- Create target module original path
mkdir -p src/github.com/target
- change target to username project creator or organization
- Go to target path
cd src/github.com/target
- Clone Forked Project in current path
git clone https://github.com/your_username/project.git
- Go to project folder
cd project
- Getting required packages via
go get ./...
- Add remote
git remote add upstream https://github.com/target/project.git
to update your fork repo. - Working on Project and send yours PR
- 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
orgit push origin branch1