Where my project folder is wrong?

Hi, I have some difficulties to understand how I must organize a go project.

My project build two binaries, a client a a server. It is composed by:

  • public package used with “mod”
  • private package used with “mod”
  • local package for function which are common to the two binaries.

I used this folder tree:

git.company.com/my-project
  + go.mod
  + cmd
  |   + server
  |   |   + go-files / package main / import "git.company.com/my-project/local-package-1"
  |   + client
  |       + go-files / package main
  + local-package-1
  |   + go-files / package local-package-1
  + local-package-2
      + go-files / package local-package-2 / import "git.company.com/my-project/local-package-1"

go.mod is like this:

module git.company.com/my-project

go 1.14

// The following line seems not have effect
replace git.company.com/my-project/ => ./

require (
    git.company.com/go-toolbox-1 v0.0.0-xxx-xxx
    git.company.com/go-toolbox-2 v0.0.0-xxx-xxx
    github.com/lib/pq v1.9.0
    github.com/mattn/go-sqlite3 v1.14.5
)

I build like this:

cd cmd/server && GO111MODULE=on go build

It works

I can update modules from the root project like this:

go get -u github.com/lib/pq

It works

But I cant update all dependecies at once from the root project:

go get -u
go get .: path /Users/xxx/git/my-project is not a package in module rooted at /Users/xxx/git/my-project

I think that I miss something. I tried to understand, and imitate https://github.com/golang-standards/project-layout, but without success.

Note, except the go get -u, I can build my tools and the projects works.

Anyone can help me ?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.