Module can't find itself

362 views
Skip to first unread message

Marcin Romaszewicz

unread,
Jul 25, 2019, 12:11:34 AM7/25/19
to golang-nuts
Hi All,

I've got a module problem which I don't quite understand. All my code is here:
When I run "go build" from the top of the repo, I get:
$ go build
can't load package: package github.com/deepmap/oapi-codegen: unknown import path "github.com/deepmap/oapi-codegen": cannot find module providing package github.com/deepmap/oapi-codegen

However, this works:
$ go build ./...

Why can't my module find itself?

I am using Go 1.12.7 on OS X. GO111MODULE=auto, and I am not in my $GOPATH. The
go.mod contains:
module github.com/deepmap/oapi-codegen

require (... <lots of stuff> ...)

The same issue happens with go generate, go test, etc, but that makes sense as it all builds on top of the build command.

Thanks for any tips,
-- Marcin

Burak Serdar

unread,
Jul 25, 2019, 12:32:05 AM7/25/19
to Marcin Romaszewicz, golang-nuts
On Wed, Jul 24, 2019 at 10:11 PM Marcin Romaszewicz <mar...@gmail.com> wrote:
>
> Hi All,
>
> I've got a module problem which I don't quite understand. All my code is here:
> https://github.com/deepmap/oapi-codegen
>
> When I run "go build" from the top of the repo, I get:
> $ go build
> can't load package: package github.com/deepmap/oapi-codegen: unknown import path "github.com/deepmap/oapi-codegen": cannot find module providing package github.com/deepmap/oapi-codegen

You're trying to build oapi-codegen package, which has no go files to build.

Try go build <path_to_main.go>

>
> However, this works:
> $ go build ./...
>
> Why can't my module find itself?
>
> I am using Go 1.12.7 on OS X. GO111MODULE=auto, and I am not in my $GOPATH. The
> go.mod contains:
> module github.com/deepmap/oapi-codegen
>
> require (... <lots of stuff> ...)
>
> The same issue happens with go generate, go test, etc, but that makes sense as it all builds on top of the build command.
>
> Thanks for any tips,
> -- Marcin
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29LsHRrbULJDcT8kP8fnmP%3Dc8G0Oa1PXwLZ3a%2BPzN%2BWa8wg%40mail.gmail.com.

Marcin Romaszewicz

unread,
Jul 25, 2019, 2:15:45 AM7/25/19
to Burak Serdar, golang-nuts
Thanks, and duh :) I was so busy trying to figure out why it wasn't building that I neglected to check the basics.

-- Marcin

Reply all
Reply to author
Forward
0 new messages