Skip to content

Commit

Permalink
Go 1.19 (#802)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelletier committed Aug 15, 2022
1 parent fb6d1d6 commit 67bc542
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Expand Up @@ -15,6 +15,6 @@ jobs:
- name: Setup go
uses: actions/setup-go@master
with:
go-version: 1.18
go-version: 1.19
- name: Run tests with coverage
run: ./ci.sh coverage -d "${GITHUB_BASE_REF-HEAD}"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest']
go: [ '1.17', '1.18' ]
go: [ '1.18', '1.19' ]
runs-on: ${{ matrix.os }}
name: ${{ matrix.go }}/${{ matrix.os }}
steps:
Expand Down
10 changes: 5 additions & 5 deletions cmd/jsontoml/main.go
@@ -1,20 +1,20 @@
// Package jsontoml is a program that converts JSON to TOML.
//
// Usage
// # Usage
//
// Reading from stdin:
//
// cat file.json | jsontoml > file.toml
// cat file.json | jsontoml > file.toml
//
// Reading from a file:
//
// jsontoml file.json > file.toml
// jsontoml file.json > file.toml
//
// Installation
// # Installation
//
// Using Go:
//
// go install github.com/pelletier/go-toml/v2/cmd/jsontoml@latest
// go install github.com/pelletier/go-toml/v2/cmd/jsontoml@latest
package main

import (
Expand Down
10 changes: 5 additions & 5 deletions cmd/tomljson/main.go
@@ -1,20 +1,20 @@
// Package tomljson is a program that converts TOML to JSON.
//
// Usage
// # Usage
//
// Reading from stdin:
//
// cat file.toml | tomljson > file.json
// cat file.toml | tomljson > file.json
//
// Reading from a file:
//
// tomljson file.toml > file.json
// tomljson file.toml > file.json
//
// Installation
// # Installation
//
// Using Go:
//
// go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest
// go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest
package main

import (
Expand Down
10 changes: 5 additions & 5 deletions cmd/tomll/main.go
@@ -1,20 +1,20 @@
// Package tomll is a linter program for TOML.
//
// Usage
// # Usage
//
// Reading from stdin, writing to stdout:
//
// cat file.toml | tomll
// cat file.toml | tomll
//
// Reading and updating a list of files in place:
//
// tomll a.toml b.toml c.toml
// tomll a.toml b.toml c.toml
//
// Installation
// # Installation
//
// Using Go:
//
// go install github.com/pelletier/go-toml/v2/cmd/tomll@latest
// go install github.com/pelletier/go-toml/v2/cmd/tomll@latest
package main

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/tomltestgen/main.go
Expand Up @@ -3,7 +3,7 @@
//
// Within the go-toml package, run `go generate`. Otherwise, use:
//
// go run github.com/pelletier/go-toml/cmd/tomltestgen -o toml_testgen_test.go
// go run github.com/pelletier/go-toml/cmd/tomltestgen -o toml_testgen_test.go
package main

import (
Expand Down
1 change: 1 addition & 0 deletions errors.go
Expand Up @@ -103,6 +103,7 @@ func (e *DecodeError) Key() Key {
//
// The function copies all bytes used in DecodeError, so that document and
// highlight can be freely deallocated.
//
//nolint:funlen
func wrapDecodeError(document []byte, de *decodeError) *DecodeError {
offset := danger.SubsliceOffset(document, de.highlight)
Expand Down
3 changes: 1 addition & 2 deletions fuzz_test.go
@@ -1,5 +1,4 @@
//go:build go1.18
// +build go1.18
//go:build go1.18 || go1.19

package toml_test

Expand Down
8 changes: 4 additions & 4 deletions internal/ast/ast.go
Expand Up @@ -11,10 +11,10 @@ import (
//
// For example:
//
// it := n.Children()
// for it.Next() {
// it.Node()
// }
// it := n.Children()
// for it.Next() {
// it.Node()
// }
type Iterator struct {
started bool
node *Node
Expand Down
25 changes: 25 additions & 0 deletions internal/imported_tests/unmarshal_imported_test.go
Expand Up @@ -151,6 +151,7 @@ type quotedKeyMarshalTestStruct struct {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var quotedKeyMarshalTestData = quotedKeyMarshalTestStruct{
String: "Hello",
Expand All @@ -160,6 +161,7 @@ var quotedKeyMarshalTestData = quotedKeyMarshalTestStruct{
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var quotedKeyMarshalTestToml = []byte(`"Yfloat-𝟘" = 3.5
"Z.string-àéù" = "Hello"
Expand Down Expand Up @@ -272,6 +274,7 @@ var docData = testDoc{
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var mapTestDoc = testMapDoc{
Title: "TOML Marshal Testing",
Expand Down Expand Up @@ -559,17 +562,20 @@ func (c customMarshaler) MarshalTOML() ([]byte, error) {
var customMarshalerData = customMarshaler{FirstName: "Sally", LastName: "Fields"}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var customMarshalerToml = []byte(`Sally Fields`)

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var nestedCustomMarshalerData = customMarshalerParent{
Self: customMarshaler{FirstName: "Maiku", LastName: "Suteda"},
Friends: []customMarshaler{customMarshalerData},
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var nestedCustomMarshalerToml = []byte(`friends = ["Sally Fields"]
me = "Maiku Suteda"
Expand Down Expand Up @@ -611,6 +617,7 @@ func TestUnmarshalTextMarshaler(t *testing.T) {
}

// TODO: Remove nolint once type and methods are used by a test
//
//nolint:unused
type precedentMarshaler struct {
FirstName string
Expand All @@ -629,6 +636,7 @@ func (m precedentMarshaler) MarshalTOML() ([]byte, error) {
}

// TODO: Remove nolint once type and method are used by a test
//
//nolint:unused
type customPointerMarshaler struct {
FirstName string
Expand All @@ -641,6 +649,7 @@ func (m *customPointerMarshaler) MarshalTOML() ([]byte, error) {
}

// TODO: Remove nolint once type and method are used by a test
//
//nolint:unused
type textPointerMarshaler struct {
FirstName string
Expand All @@ -653,6 +662,7 @@ func (m *textPointerMarshaler) MarshalText() ([]byte, error) {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var commentTestToml = []byte(`
# it's a comment on type
Expand Down Expand Up @@ -690,6 +700,7 @@ type mapsTestStruct struct {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var mapsTestData = mapsTestStruct{
Simple: map[string]string{
Expand All @@ -713,6 +724,7 @@ var mapsTestData = mapsTestStruct{
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var mapsTestToml = []byte(`
[Other]
Expand All @@ -735,6 +747,7 @@ var mapsTestToml = []byte(`
`)

// TODO: Remove nolint once type is used by a test
//
//nolint:deadcode,unused
type structArrayNoTag struct {
A struct {
Expand All @@ -744,6 +757,7 @@ type structArrayNoTag struct {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var customTagTestToml = []byte(`
[postgres]
Expand All @@ -758,6 +772,7 @@ var customTagTestToml = []byte(`
`)

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var customCommentTagTestToml = []byte(`
# db connection
Expand All @@ -771,6 +786,7 @@ var customCommentTagTestToml = []byte(`
`)

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var customCommentedTagTestToml = []byte(`
[postgres]
Expand Down Expand Up @@ -825,6 +841,7 @@ func TestUnmarshalTabInStringAndQuotedKey(t *testing.T) {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var customMultilineTagTestToml = []byte(`int_slice = [
1,
Expand All @@ -834,6 +851,7 @@ var customMultilineTagTestToml = []byte(`int_slice = [
`)

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var testDocBasicToml = []byte(`
[document]
Expand All @@ -846,12 +864,14 @@ var testDocBasicToml = []byte(`
`)

// TODO: Remove nolint once type is used by a test
//
//nolint:deadcode
type testDocCustomTag struct {
Doc testDocBasicsCustomTag `file:"document"`
}

// TODO: Remove nolint once type is used by a test
//
//nolint:deadcode
type testDocBasicsCustomTag struct {
Bool bool `file:"bool_val"`
Expand All @@ -864,6 +884,7 @@ type testDocBasicsCustomTag struct {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,varcheck
var testDocCustomTagData = testDocCustomTag{
Doc: testDocBasicsCustomTag{
Expand Down Expand Up @@ -966,6 +987,7 @@ func TestUnmarshalInvalidPointerKind(t *testing.T) {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused
type testDuration struct {
Nanosec time.Duration `toml:"nanosec"`
Expand All @@ -980,6 +1002,7 @@ type testDuration struct {
}

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var testDurationToml = []byte(`
nanosec = "1ns"
Expand All @@ -994,6 +1017,7 @@ a_string = "15s"
`)

// TODO: Remove nolint once var is used by a test
//
//nolint:deadcode,unused,varcheck
var testDurationToml2 = []byte(`a_string = "15s"
hour = "1h0m0s"
Expand All @@ -1007,6 +1031,7 @@ sec = "1s"
`)

// TODO: Remove nolint once type is used by a test
//
//nolint:deadcode,unused
type testBadDuration struct {
Val time.Duration `toml:"val"`
Expand Down
20 changes: 10 additions & 10 deletions marshaler.go
Expand Up @@ -54,7 +54,7 @@ func NewEncoder(w io.Writer) *Encoder {
// This behavior can be controlled on an individual struct field basis with the
// inline tag:
//
// MyField `toml:",inline"`
// MyField `toml:",inline"`
func (enc *Encoder) SetTablesInline(inline bool) *Encoder {
enc.tablesInline = inline
return enc
Expand All @@ -65,7 +65,7 @@ func (enc *Encoder) SetTablesInline(inline bool) *Encoder {
//
// This behavior can be controlled on an individual struct field basis with the multiline tag:
//
// MyField `multiline:"true"`
// MyField `multiline:"true"`
func (enc *Encoder) SetArraysMultiline(multiline bool) *Encoder {
enc.arraysMultiline = multiline
return enc
Expand All @@ -89,7 +89,7 @@ func (enc *Encoder) SetIndentTables(indent bool) *Encoder {
//
// If v cannot be represented to TOML it returns an error.
//
// Encoding rules
// # Encoding rules
//
// A top level slice containing only maps or structs is encoded as [[table
// array]].
Expand Down Expand Up @@ -120,17 +120,17 @@ func (enc *Encoder) SetIndentTables(indent bool) *Encoder {
// Tables and array tables are separated by empty lines. However, consecutive
// subtables definitions are not. For example:
//
// [top1]
// [top1]
//
// [top2]
// [top2.child1]
// [top2]
// [top2.child1]
//
// [[array]]
// [[array]]
//
// [[array]]
// [array.child2]
// [[array]]
// [array.child2]
//
// Struct tags
// # Struct tags
//
// The encoding of each public struct field can be customized by the format
// string in the "toml" key of the struct field's tag. This follows
Expand Down

0 comments on commit 67bc542

Please sign in to comment.