dsvs50005 2018-10-28 19:32
浏览 165
已采纳

构建一个多可执行的Go项目

I am trying to build a micro-services architecture project in Go. I am currently using Go 1.11 which supports modules, so I put my root directory in an arbitrary chosen directory, outside of GOPATH.

If I am getting the micro-services architecture concepts right, although my microservices need to be independent, they can share dependencies (and I don't see another way to do stuff, is it?)

Below is my directory structure:

.
├── go.mod
├── lambda
│   └── account_create
│       └── main.go
├── readme.md
└── types
    ├── account.go
    ├── location.go
    ├── order.go
    ├── pricing.go
    ├── product.go
    └── types.go

Now the behavior I expected was to be able to run go build lambda/account_create and get an executable with that functionality so I can supply it to the respective AWS Lambda function.

However, when I run the command, I get:

can't load package: package lambda/account_create: unknown import path "lambda/account_create": cannot find module providing package lambda/account_create

Please explain me why this does not work and give me some advice on how a project like this should look.

Thank you very much!

Edit Here is my lambda/account_create/main.go file contents:

package account_create

import (
    "fmt"
    "roasted.ro/pkg/types"
)

func main() {
    account := types.UserAccount{Name: "Victor"}
    fmt.Printf("Welcome %s", account.Name)
}
  • 写回答

1条回答 默认 最新

    报告相同问题?

    相关推荐 更多相似问题

    悬赏问题

    • ¥15 Python算法设计Seam carving--让图片比例随心缩放
    • ¥15 页面制作,HTML CSS
    • ¥15 通个批处理实现 win7和win10 修改或设置:显示操作系统列表时间为2秒
    • ¥20 报错:Unsupported class file major version 59
    • ¥18 如何使用c++语言完成网站用户管理系统?(语言-c++)
    • ¥15 用ASP代码实现跨站脚本攻击
    • ¥15 自己写的c语言程序报错
    • ¥50 ABP中怎样接收vue上传的图片
    • ¥15 uniapp设置音频的倍速播放无效
    • ¥15 关于#hc#的问题,如何解决?