No public description
PiperOrigin-RevId: 633628775
Change-Id: Iee11b6df74e30142c5db5cbefd28e3a1c819a074
diff --git a/GOIMPORT/MANIFEST b/GOIMPORT/MANIFEST
index 7260f9f..8a98aab 100644
--- a/GOIMPORT/MANIFEST
+++ b/GOIMPORT/MANIFEST
@@ -5,13 +5,13 @@
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx BUILD
+ 3a01ef1d86a62268741125473fe51568 GOIMPORT/CONFIGURATION
-+ 69508582c0c21c5a0b48e19da184b82b GOIMPORT/MANIFEST
++ 13cc1524a68117f1b2e21d6b392ce811 GOIMPORT/MANIFEST
= 9fc9e1d6b93fb3971a451d68e21a4437 LICENSE
-+ 68587bd42e304e2816e2da57c99cb7c5 METADATA
++ 0996c12b34e73626ce1c579768154a41 METADATA
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OWNERS
= 3ec7645ccbfe13331f1675d54034d89d README.md
-= 5f4dfa7393d07daf243d8d64eb715e8b decoder.go
-= a0c0a0fe9e9c757954bca07a18482c2a decoder_test.go
+= 51f6bda406b8ea454112aa256907ac6f decoder.go
+= 9d0980c4ac284ebb5a1e309c79268ddf decoder_test.go
= a6c7fbb988e532707b47bbd31daf4676 go.mod
= 26a95cbd0a533fcf286f3b81e3951000 go.sum
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx google_init_test.go
@@ -161,9 +161,6 @@
= 5cd9f072067f7ccf981450d4d394c2be test-fixtures/assign_deep.hcl
= 29eada54d9d67b8ea3176390af2869f6 test-fixtures/basic.hcl
= 73261bc19c6516037316808dc9d0befb test-fixtures/basic.json
-= 2cfbed1438cb24a5dee8fa50745c1e71 test-fixtures/basic_bool.hcl
-= 5b4ef779c5007abca3d562b03fea6a4e test-fixtures/basic_bool_int.hcl
-= 495542dc1c801690a401eeec90960d2f test-fixtures/basic_bool_string.hcl
= 83347a9c40a9d26a7840f3ce646fa275 test-fixtures/basic_int_string.hcl
= 734b850cc4895d53e0bb0fa899600ad9 test-fixtures/basic_squish.hcl
= 957a4def52e1468cc7eb0d83b6fdd963 test-fixtures/block_assign.hcl
diff --git a/decoder.go b/decoder.go
index 0f0514f..41d3fbd 100644
--- a/decoder.go
+++ b/decoder.go
@@ -117,17 +117,10 @@
func (d *decoder) decodeBool(name string, node ast.Node, result reflect.Value) error {
switch n := node.(type) {
case *ast.LiteralType:
- switch n.Token.Type {
- case token.BOOL, token.STRING, token.NUMBER:
- var v bool
- s := strings.ToLower(strings.Replace(n.Token.Text, "\"", "", -1))
- switch s {
- case "1", "true":
- v = true
- case "0", "false":
- v = false
- default:
- return fmt.Errorf("decodeBool: Unknown value for boolean: %s", n.Token.Text)
+ if n.Token.Type == token.BOOL {
+ v, err := strconv.ParseBool(n.Token.Text)
+ if err != nil {
+ return err
}
result.Set(reflect.ValueOf(v))
diff --git a/decoder_test.go b/decoder_test.go
index d81f52f..e05e7eb 100644
--- a/decoder_test.go
+++ b/decoder_test.go
@@ -794,51 +794,6 @@
}
}
-func TestDecode_boolString(t *testing.T) {
- var value struct {
- Boolean bool
- }
-
- err := Decode(&value, testReadFile(t, "basic_bool_string.hcl"))
- if err != nil {
- t.Fatalf("err: %s", err)
- }
-
- if value.Boolean != true {
- t.Fatalf("bad: %#v", value.Boolean)
- }
-}
-
-func TestDecode_boolInt(t *testing.T) {
- var value struct {
- Boolean bool
- }
-
- err := Decode(&value, testReadFile(t, "basic_bool_int.hcl"))
- if err != nil {
- t.Fatalf("err: %s", err)
- }
-
- if value.Boolean != true {
- t.Fatalf("bad: %#v", value.Boolean)
- }
-}
-
-func TestDecode_bool(t *testing.T) {
- var value struct {
- Boolean bool
- }
-
- err := Decode(&value, testReadFile(t, "basic_bool.hcl"))
- if err != nil {
- t.Fatalf("err: %s", err)
- }
-
- if value.Boolean != true {
- t.Fatalf("bad: %#v", value.Boolean)
- }
-}
-
func TestDecode_intString(t *testing.T) {
var value struct {
Count int
diff --git a/hcl/fmtcmd/fmtcmd_test.go b/hcl/fmtcmd/fmtcmd_test.go
index 4a152ad..0b10f2f 100644
--- a/hcl/fmtcmd/fmtcmd_test.go
+++ b/hcl/fmtcmd/fmtcmd_test.go
@@ -1,4 +1,6 @@
+//go:build !windows
// +build !windows
+
// TODO(jen20): These need fixing on Windows but fmt is not used right now
// and red CI is making it harder to process other bugs, so ignore until
// we get around to fixing them.
diff --git a/hcl/printer/nodes.go b/hcl/printer/nodes.go
index 677058e..aa54d68 100644
--- a/hcl/printer/nodes.go
+++ b/hcl/printer/nodes.go
@@ -721,10 +721,9 @@
//
// A single line object:
//
-// * has no lead comments (hence multi-line)
-// * has no assignment
-// * has no values in the stanza (within {})
-//
+// - has no lead comments (hence multi-line)
+// - has no assignment
+// - has no values in the stanza (within {})
func (p *printer) isSingleLineObject(val *ast.ObjectItem) bool {
// If there is a lead comment, can't be one line
if val.LeadComment != nil {