Skip to content

Commit

Permalink
Use Go 1.20
Browse files Browse the repository at this point in the history
Versions before this are unsupported by the Go team anyway, but the main
reason is because our pull request checks workflow uses this to determine
which toolchain version to run the tests with.

This also brings in the new "go fmt" conventions for godoc comments, so
this commit updates them all to match those conventions.
  • Loading branch information
apparentlymart committed Mar 12, 2024
1 parent 89f41a8 commit f2033bd
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 47 deletions.
2 changes: 1 addition & 1 deletion diagnostic.go
Expand Up @@ -121,7 +121,7 @@ func (d Diagnostics) Error() string {
// This is provided as a convenience for returning from a function that
// collects and then returns a set of diagnostics:
//
// return nil, diags.Append(&hcl.Diagnostic{ ... })
// return nil, diags.Append(&hcl.Diagnostic{ ... })
//
// Note that this modifies the array underlying the diagnostics slice, so
// must be used carefully within a single codepath. It is incorrect (and rude)
Expand Down
32 changes: 16 additions & 16 deletions doc.go
Expand Up @@ -9,25 +9,25 @@
// configurations in either native HCL syntax or JSON syntax into a Go struct
// type:
//
// package main
// package main
//
// import (
// "log"
// "github.com/hashicorp/hcl/v2/hclsimple"
// )
// import (
// "log"
// "github.com/hashicorp/hcl/v2/hclsimple"
// )
//
// type Config struct {
// LogLevel string `hcl:"log_level"`
// }
// type Config struct {
// LogLevel string `hcl:"log_level"`
// }
//
// func main() {
// var config Config
// err := hclsimple.DecodeFile("config.hcl", nil, &config)
// if err != nil {
// log.Fatalf("Failed to load configuration: %s", err)
// }
// log.Printf("Configuration is %#v", config)
// }
// func main() {
// var config Config
// err := hclsimple.DecodeFile("config.hcl", nil, &config)
// if err != nil {
// log.Fatalf("Failed to load configuration: %s", err)
// }
// log.Printf("Configuration is %#v", config)
// }
//
// If your application needs more control over the evaluation of the
// configuration, you can use the functions in the subdirectories hclparse,
Expand Down
6 changes: 3 additions & 3 deletions ext/typeexpr/doc.go
Expand Up @@ -8,7 +8,7 @@
// use any of the usual language operators. This is similar to type expressions
// in statically-typed programming languages.
//
// variable "example" {
// type = list(string)
// }
// variable "example" {
// type = list(string)
// }
package typeexpr
3 changes: 2 additions & 1 deletion ext/typeexpr/type_type.go
Expand Up @@ -46,7 +46,8 @@ func TypeConstraintFromVal(v cty.Value) cty.Type {
// ConvertFunc is a cty function that implements type conversions.
//
// Its signature is as follows:
// convert(value, type_constraint)
//
// convert(value, type_constraint)
//
// ...where type_constraint is a type constraint expression as defined by
// typeexpr.TypeConstraint.
Expand Down
8 changes: 4 additions & 4 deletions ext/userfunc/doc.go
Expand Up @@ -10,10 +10,10 @@
//
// The function declaration syntax looks like this:
//
// function "foo" {
// params = ["name"]
// result = "Hello, ${name}!"
// }
// function "foo" {
// params = ["name"]
// result = "Hello, ${name}!"
// }
//
// When a user-defined function is called, the expression given for the "result"
// attribute is evaluated in an isolated evaluation context that defines variables
Expand Down
2 changes: 1 addition & 1 deletion go.mod
@@ -1,6 +1,6 @@
module github.com/hashicorp/hcl/v2

go 1.18
go 1.20

require (
github.com/agext/levenshtein v1.2.1
Expand Down
12 changes: 6 additions & 6 deletions gohcl/doc.go
Expand Up @@ -10,18 +10,18 @@
// A struct field tag scheme is used, similar to other decoding and
// unmarshalling libraries. The tags are formatted as in the following example:
//
// ThingType string `hcl:"thing_type,attr"`
// ThingType string `hcl:"thing_type,attr"`
//
// Within each tag there are two comma-separated tokens. The first is the
// name of the corresponding construct in configuration, while the second
// is a keyword giving the kind of construct expected. The following
// kind keywords are supported:
//
// attr (the default) indicates that the value is to be populated from an attribute
// block indicates that the value is to populated from a block
// label indicates that the value is to populated from a block label
// optional is the same as attr, but the field is optional
// remain indicates that the value is to be populated from the remaining body after populating other fields
// attr (the default) indicates that the value is to be populated from an attribute
// block indicates that the value is to populated from a block
// label indicates that the value is to populated from a block label
// optional is the same as attr, but the field is optional
// remain indicates that the value is to be populated from the remaining body after populating other fields
//
// "attr" fields may either be of type *hcl.Expression, in which case the raw
// expression is assigned, or of any type accepted by gocty, in which case
Expand Down
8 changes: 4 additions & 4 deletions hclwrite/parser.go
Expand Up @@ -521,10 +521,10 @@ func writerTokens(nativeTokens hclsyntax.Tokens) Tokens {
// boundaries, such that the slice operator could be used to produce
// three token sequences for before, within, and after respectively:
//
// start, end := partitionTokens(toks, rng)
// before := toks[:start]
// within := toks[start:end]
// after := toks[end:]
// start, end := partitionTokens(toks, rng)
// before := toks[:start]
// within := toks[start:end]
// after := toks[end:]
//
// This works best when the range is aligned with token boundaries (e.g.
// because it was produced in terms of the scanner's result) but if that isn't
Expand Down
22 changes: 11 additions & 11 deletions traversal_for_expr.go
Expand Up @@ -74,7 +74,7 @@ func RelTraversalForExpr(expr Expression) (Traversal, Diagnostics) {
// For example, the following attribute has an expression that would produce
// the keyword "foo":
//
// example = foo
// example = foo
//
// This function is a variant of AbsTraversalForExpr, which uses the same
// interface on the given expression. This helper constrains the result
Expand All @@ -84,16 +84,16 @@ func RelTraversalForExpr(expr Expression) (Traversal, Diagnostics) {
// situations where one of a fixed set of keywords is required and arbitrary
// expressions are not allowed:
//
// switch hcl.ExprAsKeyword(expr) {
// case "allow":
// // (take suitable action for keyword "allow")
// case "deny":
// // (take suitable action for keyword "deny")
// default:
// diags = append(diags, &hcl.Diagnostic{
// // ... "invalid keyword" diagnostic message ...
// })
// }
// switch hcl.ExprAsKeyword(expr) {
// case "allow":
// // (take suitable action for keyword "allow")
// case "deny":
// // (take suitable action for keyword "deny")
// default:
// diags = append(diags, &hcl.Diagnostic{
// // ... "invalid keyword" diagnostic message ...
// })
// }
//
// The above approach will generate the same message for both the use of an
// unrecognized keyword and for not using a keyword at all, which is usually
Expand Down

0 comments on commit f2033bd

Please sign in to comment.