-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: get go: use constant.Value.ExactString to extract constant
Currently long string constant values break during the import because of the use of go/constant.Value.String() (which is the short version). Switch to using go/constant.Value.ExactString() for the complete value. Add a basic testscript test whilst we are at it. Fixes #458 Change-Id: I1a2973d008bd517d47474becf5dbbfb3df22ecfa Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6781 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
- Loading branch information
Showing
3 changed files
with
50 additions
and
3 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Test that a basic get go works using golden files to verify output | ||
|
||
# Set HOME for go-build cache to be valid | ||
env HOME=$WORK${/}home | ||
env USERPROFILE=$HOME | ||
env LOCALAPPDATA=$WORK${/}appdata | ||
|
||
# All the things | ||
cue get go --local | ||
cmp blah_go_gen.cue all.cue.golden | ||
|
||
-- go.mod -- | ||
module mod.com/blah | ||
-- blah.go -- | ||
package main | ||
|
||
type S struct { | ||
Name string | ||
T | ||
} | ||
|
||
type T struct { | ||
Age int | ||
} | ||
|
||
const ( | ||
LongStringConst = "This is a really long string. Why are we using a long string? Because that way it ensures we are using go/constant.Value.ExactString() instead of go/constant.Value.String()" | ||
IntConst = "test" | ||
) | ||
-- all.cue.golden -- | ||
// Code generated by cue get go. DO NOT EDIT. | ||
|
||
//cue:generate cue get go mod.com/blah | ||
|
||
package main | ||
|
||
#S: { | ||
Name: string | ||
T: #T | ||
} | ||
|
||
#T: Age: int | ||
|
||
#LongStringConst: "This is a really long string. Why are we using a long string? Because that way it ensures we are using go/constant.Value.ExactString() instead of go/constant.Value.String()" | ||
#IntConst: "test" |