This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: embed packages required for get go checking
'cue get go' loads interface types from cmd/cue/cmd/interfaces during initialisation. Go types that satisfy these interface types are then used as special cases for the target CUE definition types - see the complete logic in (*extractor).altType. Given the nature of 'cue get go', it is assumed that the command is run in the context of a Go module. That is to say, 'go env GOMOD' will be non-empty. (It doesn't seem worth adding GOPATH support given that modules will be GA in Go 1.16) Currently, 'cue get go' assumes that the package cuelang.org/go/cmd/cue/cmd/interfaces will be available. That is to say, either cuelang.org/go is the main module or, more likely, that cuelang.org/go is a module dependency of the main module. However, this is an unnecessary restriction and one that is potentially incorrect. After all, the user is using a specific version of cmd/cue - loading a different version of cuelang.org/go seems likely to lead to version-skew related problems. This change switches cmd/cue to instead load cuelang.org/go/cmd/cue/cmd/interfaces via a simple embedding of the GoFiles in that package. As part of the same change we surface all loading and type checking errors for either the embedded cuelang.org/go/cmd/cue/cmd/interfaces or the arguments to 'cue get go'. With thanks to @verdverm and @NicolasRouquette for the analysis and suggestions that went into this fix. Drops GOPATH support. Fixes #621 Fixes #668 Change-Id: I630e2cb167c05d63186aa356eaf70a58749b61c5
- Loading branch information
Showing
20 changed files
with
827 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.