Skip to content

cmd/go: go install / go.mod / go:embed / build tags don't play well together. #47109

Closed
@james-lawrence

Description

@james-lawrence

have a program where I have three files:

workspace_16.go which contains // +build go1.16 and a go:embed
workspace_15.go // +build !go1.16
workspace.go

and a go.mod with
go 1.14

cmd/bw/workspace_16.go:64:3: go:embed requires go1.16 or later (-lang was set to go1.14; check go.mod)

expect it to build properly.

Activity

changed the title [-]go install / go.mod / go:embed / build tags don't play well together.[/-] [+]cmd/go: go install / go.mod / go:embed / build tags don't play well together.[/+] on Jul 9, 2021
jayconrod

jayconrod commented on Jul 9, 2021

@jayconrod
Contributor

The go directive in go.mod is the problem here. It needs to be go 1.16 or higher.

Closing since this seems like it's working as intended. Your +build tags look like they should work.

But #30791 is related. The go directive is not all that well-documented or understood.

james-lawrence

james-lawrence commented on Jul 10, 2021

@james-lawrence
ContributorAuthor

@jayconrod I believe you misunderstood the problem. it doesn't build, the source code with the build tags should build properly for both go 1.14, 1.15, and 1.16. 1.16 isn't the minimum version. changing go.mod to use version 1.16 would prevent it from building with go 1.14.

edit: waiting on results from CI, I believe i may have made an erroneous assumption on the build failure based on local builds. =)

james-lawrence

james-lawrence commented on Jul 10, 2021

@james-lawrence
ContributorAuthor

@jayconrod nm then, I stand corrected. the error in CI was from an import that didn't get autoremoved during save. sigh

locked and limited conversation to collaborators on Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jayconrod@james-lawrence@gopherbot

        Issue actions

          cmd/go: go install / go.mod / go:embed / build tags don't play well together. · Issue #47109 · golang/go