go - Golang project structure in an application versus a package -


my organization uses rails develop app i'm attempting re-write 1 of our back-end processes in golang because it's quicker.

i've structure application our company namespace app (example.co), , subfolder each of packages within app.

each library i've included (e.g. sqlx, etc...) has it's own folder.

src/   github.com/     jmoiron/       (sqlx package files)   example.co     my_app/       (my app package files)     model/       (model package files...) 

however looking @ other packages sqlx, appears scrap directory structure entirely , put files in root directory

is because i'm writing application , sqlx package that's meant included in other applications? or difference in preference since there's no real accepted "standard"

i did on first project. have since learned:

  • the $gopath/bin/ pkg/ src/ layout constructed go get , similar commands
  • you can organize .go files single flat project dir or subfolders (caveat: .go files in same folder must have same package name)
  • put other people's code in /vendor directory inside project root, if code app needs work (google this, it's worst part of go imo)
  • put own project under gopath, symlink if want more accessible

so imagine code like:

/users/user2490003/mygopath/ ▾ src/github.com/user2490003/myproject/   ▾ model/       user.go   ▾ myapp/       myapp.go   ▾ vendor/github.com/jmoiron/sqlx/       sqlx.go     main.go 

import full package references, this:

// main.go package main import (   github.com/jmoiron/sqlx   github.com/user2490003/myproject/myapp   github.com/user2490003/myproject/model ) 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo