混淆golang项目布局回购在实践中的工作方式

This question is in reference to the popular project-layout. Is this simply a way to lay out the code, but the actual compilation of a binary will be in the

/cmd/app1/
/cmd/app2/

So if I have a website, it would still be considered a cmd application that would simply start the http listener etc.

Or are there several "entry" points throughout the layout and not just in the cmd folders?

How exactly would you actual build and run your application using this layout? (or one of them since from what I understand it supports multiple)

is it like:

go build cmd/app1/*.go ?

You can just

go build ./cmd/app/

For example I have this module

├── cmd
│   ├── cli
│   │   └── main.go
│   └── web
│       └── main.go
├── go.mod
└── service
    └── service.go

go.mod is just

module example

service.go:

package service

import "fmt"

func DoSomething() {
    fmt.Println("service processing")
}

cmd/web/main.go:

package main

import (
    "example/service"
    "fmt"
)

func main() {
    fmt.Println("starting web program")
    service.DoSomething()
}

cmd/cli/main.go:

package main

import (
    "example/service"
    "fmt"
)

func main() {
    fmt.Println("starting cli program")
    service.DoSomething()
}

Build (From root)

Build web:

go build ./cmd/web/

This will create binary file web

run web

./web
// output:
// starting web program
// service processing

Build cli:

go build ./cmd/cli/

run web

./web
// output:
// starting cli program
// service processing

If you want to build all of your apps inside a folder you can do like this :

go install ./...

this will build all your apps in bin folder inside GOPATH then you can run whatever app you like.
But if you want to build and run a specific app you can go to that folder and simply run.

go build 

As long as there is a main package in that folder you can build your program.