Package Oriented Design in GO


@SatyamZode


Package Oriented Design Philosophies

  • Purpose
  • Usability
  • Portability

Project Structure


Kit                     Application

├── CONTRIBUTORS        ├── cmd/
├── LICENSE             ├── internal/
├── README.md           │   └── platform/
├── cfg/                └── vendor/
├── examples/
├── log/
├── pool/
├── tcp/
├── timezone/
├── udp/
└── web/

Listing 1


github.com/ardanlabs/kit
├── CONTRIBUTORS
├── LICENSE
├── README.md
├── cfg/
├── examples/
├── log/
├── pool/
├── tcp/
├── timezone/
├── udp/
└── web/

Listing 2


github.com/servi-io/api
├── cmd/
│   ├── servi/
│   │   ├── cmdupdate/
│   │   ├── cmdquery/
│   │   └── servi.go
│   └── servid/
│       ├── routes/
│       │   └── handlers/
│       ├── tests/
│       └── servid.go
├── internal/
│   ├── attachments/
│   ├── locations/
│   ├── orders/
│   │   ├── customers/
│   │   ├── items/
│   │   ├── tags/
│   │   └── orders.go
│   ├── registrations/
│   └── platform/
│       ├── crypto/
│       ├── mongo/
│       └── json/
└── vendor/
    ├── github.com/
    │   ├── ardanlabs/
    │   ├── golang/
    │   ├── prometheus/
    └── golang.org/

Contributing to (Forked) Golang Projects


Why? What's the problem?

Problem :


[email protected]:~/go/src/github.com/satyamz/Tasks$ go build 
main.go:13:2: cannot find package "github.com/thewhitetulip/Tasks/config" in any of:
    /usr/local/go/src/github.com/thewhitetulip/Tasks/config (from $GOROOT)
    /home/cb/go/src/github.com/thewhitetulip/Tasks/config (from $GOPATH)
main.go:14:2: cannot find package "github.com/thewhitetulip/Tasks/views" in any of:
    /usr/local/go/src/github.com/thewhitetulip/Tasks/views (from $GOROOT)
    /home/cb/go/src/github.com/thewhitetulip/Tasks/views (from $GOPATH)
[email protected]:~/go/src/github.com/satyamz/Tasks$

Contributing to (Forked) Golang Projects : Solution 1


Add Remote

  • Go get the main repo
           $go get github.com/thewhitetulip/Tasks
  • Add your forked repo as a remote
           $git remote add satyamz-tasks-fork http://github.com/satyamz/Tasks
  • Work with your remote
           $git pull --rebase satyamz-tasks-fork
           $git push satyamz-tasks-fork

Contributing to (Forked) Golang Projects : Solution 2


Cheat 'go get'

cd $GOPATH

mkdir -p {src,bin,pkg}

mkdir -p src/github.com/thewhitetulip/

cd src/github.com/thewhitetulip/

git clone [email protected]:satyamz/Tasks.git # OR: git clone https://github.com/satyamz/Tasks.git

cd Tasks/

go get ./...

References :

Thank you!

Join Us