Skip to content

Commit

Permalink
all: unconvert -apply ./...
Browse files Browse the repository at this point in the history
Minus the vendored golangorgx code.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I58d838c38b38911d6a731d386dc98c1012627aae
Dispatch-Trailer: {"type":"trybot","CL":1210505,"patchset":1,"ref":"refs/changes/05/1210505/1","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Mar 5, 2025
1 parent 8923963 commit f42cf04
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cue/ast/astutil/sanitize.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (z *sanitizer) uniqueName(base string, hidden bool) string {

const mask = 0xff_ffff_ffff_ffff // max bits; stay clear of int64 overflow
const shift = 4 // rate of growth
for n := int64(0x10); ; n = int64(mask&((n<<shift)-1)) + 1 {
for n := int64(0x10); ; n = mask&((n<<shift)-1) + 1 {
num := z.rand.Intn(int(n))
name := fmt.Sprintf("%s_%01X", base, num)
if !z.names[name] {
Expand Down
2 changes: 1 addition & 1 deletion cue/parser/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func expectedErrors(t *testing.T, file *token.File, src []byte) map[token.Pos]st
if s[1] == "HERE" {
pos = here
}
errors[pos] = string(s[2])
errors[pos] = s[2]
}
default:
prev = pos
Expand Down
4 changes: 2 additions & 2 deletions cue/token/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (f *File) Pos(offset int, rel RelPos) Pos {
// f.Offset(f.Pos(offset)) == offset.
func (f *File) Offset(p Pos) int {
x := p.index()
if x < 1 || x > 1+index(f.size) {
if x < 1 || x > 1+f.size {
panic("illegal Pos value")
}
return int(x - 1)
Expand All @@ -436,7 +436,7 @@ func searchLineInfos(a []lineInfo, x int) int {
func (f *File) unpack(offset index, adjusted bool) (filename string, line, column int) {
filename = f.name
if i := searchInts(f.lines, offset); i >= 0 {
line, column = int(i+1), int(offset-f.lines[i]+1)
line, column = i+1, int(offset-f.lines[i]+1)
}
if adjusted && len(f.infos) > 0 {
// almost no files have extra line infos
Expand Down
2 changes: 1 addition & 1 deletion cue/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ func (v Value) checkKind(ctx *adt.OpContext, want adt.Kind) *adt.Bottom {

func makeInt(v Value, x int64) Value {
n := &adt.Num{K: adt.IntKind}
n.X.SetInt64(int64(x))
n.X.SetInt64(x)
return remakeFinal(v, n)
}

Expand Down
2 changes: 1 addition & 1 deletion cue/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func TestInt(t *testing.T) {

vu, err := n.Uint64()
checkErr(t, err, tc.errU, "Uint64")
if vu != uint64(tc.uint) {
if vu != tc.uint {
t.Errorf("Uint64: got %v; want %v", vu, tc.uint)
}
})
Expand Down
6 changes: 3 additions & 3 deletions encoding/openapi/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (b *builder) fillSchema(v cue.Value) *ast.StructLit {
}

schema := b.finish()
s := (*ast.StructLit)(schema)
s := schema

simplify(b, s)

Expand Down Expand Up @@ -529,7 +529,7 @@ func (b *builder) disjunction(a []cue.Value, f typeFunc) {
c := newOASBuilder(b)
c.value(v, f)
t := c.finish()
schemas[i] = (*ast.StructLit)(t)
schemas[i] = t
if len(t.Elts) == 0 {
if c.typ == "" {
return
Expand Down Expand Up @@ -1207,7 +1207,7 @@ func (b *builder) add(t *ast.StructLit) {
func (b *builder) addConjunct(f func(*builder)) {
c := newOASBuilder(b)
f(c)
b.add((*ast.StructLit)(c.finish()))
b.add(c.finish())
}

func (b *builder) addRef(v cue.Value, inst cue.Value, ref cue.Path) {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/compile/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c *compiler) label(n ast.Node) adt.Feature {
return adt.InvalidLabel
}

i := int64(index.StringToIndex(norm.NFC.String(s)))
i := index.StringToIndex(norm.NFC.String(s))
f, err := adt.MakeLabel(n, i, adt.StringLabel)
if err != nil {
c.errf(n, msg, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/core/convert/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (c *goConverter) convertRec(nilIsTop bool, x interface{}) (result adt.Value
case int32:
return c.toInt(int64(v))
case int64:
return c.toInt(int64(v))
return c.toInt(v)
case uint:
return c.toUint(uint64(v))
case uint8:
Expand All @@ -354,7 +354,7 @@ func (c *goConverter) convertRec(nilIsTop bool, x interface{}) (result adt.Value
case uint32:
return c.toUint(uint64(v))
case uint64:
return c.toUint(uint64(v))
return c.toUint(v)
case uintptr:
return c.toUint(uint64(v))
case float64:
Expand Down
2 changes: 1 addition & 1 deletion internal/core/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func findUnique(set featureSet, base string) (f adt.Feature, name string) {
const mask = 0xff_ffff_ffff_ffff // max bits; stay clear of int64 overflow
const shift = 4 // rate of growth
digits := 1
for n := int64(0x10); ; n = int64(mask&((n<<shift)-1)) + 1 {
for n := int64(0x10); ; n = mask&((n<<shift)-1) + 1 {
num := set.intn(int(n)-1) + 1
name := fmt.Sprintf("%[1]s_%0[2]*[3]X", base, digits, num)
if f, ok := set.makeFeature(name); ok {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/export/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (e *exporter) stringLabel(f adt.Feature) ast.Label {
x := f.Index()
switch f.Typ() {
case adt.IntLabel:
return ast.NewLit(token.INT, strconv.Itoa(int(x)))
return ast.NewLit(token.INT, strconv.Itoa(x))

case adt.DefinitionLabel, adt.HiddenLabel, adt.HiddenDefinitionLabel:
s := e.identString(f)
Expand Down
4 changes: 2 additions & 2 deletions internal/core/export/value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func TestValueX(t *testing.T) {
a := cuetxtar.Load(archive, t.TempDir())

r := runtime.New()
(*runtime.Runtime)(r).SetVersion(internal.DevVersion)
(*runtime.Runtime)(r).SetDebugOptions(&cuedebug.Config{Sharing: true})
r.SetVersion(internal.DevVersion)
r.SetDebugOptions(&cuedebug.Config{Sharing: true})

v, errs := compile.Files(nil, r, "", a[0].Files...)
if errs != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/mod/modpkgload/pkgload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestLoadPackages(t *testing.T) {
}
}
}
if diff := cmp.Diff(string(want), out.String()); diff != "" {
if diff := cmp.Diff(want, out.String()); diff != "" {
t.Logf("actual result:\n%s", out.String())
t.Fatalf("unexpected results (-want +got):\n%s", diff)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (c *CallCtxt) Int8(i int) int8 { return int8(c.intValue(i, 8, "int8")) }
func (c *CallCtxt) Int16(i int) int16 { return int16(c.intValue(i, 16, "int16")) }
func (c *CallCtxt) Int32(i int) int32 { return int32(c.intValue(i, 32, "int32")) }
func (c *CallCtxt) Rune(i int) rune { return rune(c.intValue(i, 32, "rune")) }
func (c *CallCtxt) Int64(i int) int64 { return int64(c.intValue(i, 64, "int64")) }
func (c *CallCtxt) Int64(i int) int64 { return c.intValue(i, 64, "int64") }

func (c *CallCtxt) intValue(i, bits int, typ string) int64 {
arg := c.args[i]
Expand All @@ -132,7 +132,7 @@ func (c *CallCtxt) Uint8(i int) uint8 { return uint8(c.uintValue(i, 8, "uint8"
func (c *CallCtxt) Byte(i int) uint8 { return byte(c.uintValue(i, 8, "byte")) }
func (c *CallCtxt) Uint16(i int) uint16 { return uint16(c.uintValue(i, 16, "uint16")) }
func (c *CallCtxt) Uint32(i int) uint32 { return uint32(c.uintValue(i, 32, "uint32")) }
func (c *CallCtxt) Uint64(i int) uint64 { return uint64(c.uintValue(i, 64, "uint64")) }
func (c *CallCtxt) Uint64(i int) uint64 { return c.uintValue(i, 64, "uint64") }

func (c *CallCtxt) uintValue(i, bits int, typ string) uint64 {
x := value.Make(c.ctx, c.args[i])
Expand Down
20 changes: 10 additions & 10 deletions pkg/uuid/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ func Valid(s string) error {
// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
func Parse(s string) (string, error) {
x, err := uuid.Parse(s)
return string(x.String()), err
return x.String(), err
}

// TODO(mvdan): what is ToString meant to do? it appears like a no-op?

// String represents a 128-bit UUID value as a string.
func ToString(x string) string {
return string(x)
return x
}

// URN reports the canonical URN of a UUID.
func URN(x string) (string, error) {
u, err := uuid.Parse(string(x))
u, err := uuid.Parse(x)
if err != nil {
return "", err
}
Expand All @@ -66,7 +66,7 @@ func FromInt(i *big.Int) (string, error) {
b = buf[:]
}
u, err := uuid.FromBytes(b)
return string(u.String()), err
return u.String(), err
}

// ToInt represents a UUID string as a 128-bit value.
Expand All @@ -78,7 +78,7 @@ func ToInt(x string) *big.Int {

// Variant reports the UUID variant.
func Variant(x string) (int, error) {
u, err := uuid.Parse(string(x))
u, err := uuid.Parse(x)
if err != nil {
return 0, err
}
Expand All @@ -87,7 +87,7 @@ func Variant(x string) (int, error) {

// Version reports the UUID version.
func Version(x string) (int, error) {
u, err := uuid.Parse(string(x))
u, err := uuid.Parse(x)
if err != nil {
return 0, err
}
Expand All @@ -96,19 +96,19 @@ func Version(x string) (int, error) {

// SHA1 generates a version 5 UUID based on the supplied name space and data.
func SHA1(space string, data []byte) (string, error) {
u, err := uuid.Parse(string(space))
u, err := uuid.Parse(space)
if err != nil {
return "", err
}
return string(uuid.NewSHA1(u, data).String()), nil
return uuid.NewSHA1(u, data).String(), nil
}

// MD5 generates a version 3 UUID based on the supplied name space and data.
// Use SHA1 instead if you can.
func MD5(space string, data []byte) (string, error) {
u, err := uuid.Parse(string(space))
u, err := uuid.Parse(space)
if err != nil {
return "", err
}
return string(uuid.NewMD5(u, data).String()), nil
return uuid.NewMD5(u, data).String(), nil
}

0 comments on commit f42cf04

Please sign in to comment.