Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f445202cb8 |
+18
-14
@@ -74,39 +74,43 @@ universal_binaries:
|
|||||||
name_template: jsontoml
|
name_template: jsontoml
|
||||||
archives:
|
archives:
|
||||||
- id: jsontoml
|
- id: jsontoml
|
||||||
format: tar.xz
|
formats:
|
||||||
builds:
|
- tar.xz
|
||||||
|
ids:
|
||||||
- jsontoml
|
- jsontoml
|
||||||
files:
|
files:
|
||||||
- none*
|
- none*
|
||||||
name_template: "{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}"
|
name_template: "{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}"
|
||||||
- id: tomljson
|
- id: tomljson
|
||||||
format: tar.xz
|
formats:
|
||||||
builds:
|
- tar.xz
|
||||||
|
ids:
|
||||||
- tomljson
|
- tomljson
|
||||||
files:
|
files:
|
||||||
- none*
|
- none*
|
||||||
name_template: "{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}"
|
name_template: "{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}"
|
||||||
- id: tomll
|
- id: tomll
|
||||||
format: tar.xz
|
formats:
|
||||||
builds:
|
- tar.xz
|
||||||
|
ids:
|
||||||
- tomll
|
- tomll
|
||||||
files:
|
files:
|
||||||
- none*
|
- none*
|
||||||
name_template: "{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}"
|
name_template: "{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}"
|
||||||
dockers:
|
dockers_v2:
|
||||||
- id: tools
|
- id: tools
|
||||||
goos: linux
|
|
||||||
goarch: amd64
|
|
||||||
ids:
|
ids:
|
||||||
- jsontoml
|
- jsontoml
|
||||||
- tomljson
|
- tomljson
|
||||||
- tomll
|
- tomll
|
||||||
image_templates:
|
images:
|
||||||
- "ghcr.io/pelletier/go-toml:latest"
|
- "ghcr.io/pelletier/go-toml"
|
||||||
- "ghcr.io/pelletier/go-toml:{{ .Tag }}"
|
tags:
|
||||||
- "ghcr.io/pelletier/go-toml:v{{ .Major }}"
|
- "latest"
|
||||||
skip_push: false
|
- "{{ .Tag }}"
|
||||||
|
- "v{{ .Major }}"
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
checksum:
|
checksum:
|
||||||
name_template: 'sha256sums.txt'
|
name_template: 'sha256sums.txt'
|
||||||
snapshot:
|
snapshot:
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
FROM scratch
|
FROM scratch
|
||||||
ENV PATH "$PATH:/bin"
|
ENV PATH "$PATH:/bin"
|
||||||
COPY tomll /bin/tomll
|
ARG TARGETPLATFORM
|
||||||
COPY tomljson /bin/tomljson
|
COPY $TARGETPLATFORM/tomll /bin/tomll
|
||||||
COPY jsontoml /bin/jsontoml
|
COPY $TARGETPLATFORM/tomljson /bin/tomljson
|
||||||
|
COPY $TARGETPLATFORM/jsontoml /bin/jsontoml
|
||||||
|
|||||||
@@ -286,27 +286,6 @@ func TestDecodeError_Position(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecodeError_InvalidKeyStartAfterComment(t *testing.T) {
|
|
||||||
doc := "# comment\n= \"value\""
|
|
||||||
|
|
||||||
var out map[string]string
|
|
||||||
err := Unmarshal([]byte(doc), &out)
|
|
||||||
assert.Error(t, err)
|
|
||||||
|
|
||||||
var derr *DecodeError
|
|
||||||
if !errors.As(err, &derr) {
|
|
||||||
t.Fatal("error not in expected format")
|
|
||||||
}
|
|
||||||
|
|
||||||
row, col := derr.Position()
|
|
||||||
assert.Equal(t, 2, row)
|
|
||||||
assert.Equal(t, 1, col)
|
|
||||||
assert.Equal(t, "toml: invalid character at start of key: =", derr.Error())
|
|
||||||
assert.Equal(t, `1| # comment
|
|
||||||
2| = "value"
|
|
||||||
| ~ invalid character at start of key: =`, derr.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStrictErrorUnwrap(t *testing.T) {
|
func TestStrictErrorUnwrap(t *testing.T) {
|
||||||
fo := bytes.NewBufferString(`
|
fo := bytes.NewBufferString(`
|
||||||
Missing = 1
|
Missing = 1
|
||||||
|
|||||||
+3
-16
@@ -3,7 +3,6 @@ package unstable
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/pelletier/go-toml/v2/internal/characters"
|
"github.com/pelletier/go-toml/v2/internal/characters"
|
||||||
@@ -84,22 +83,10 @@ func (p *Parser) rangeOfToken(token, rest []byte) Range {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// subsliceOffset returns the byte offset of subslice b within p.data.
|
// subsliceOffset returns the byte offset of subslice b within p.data.
|
||||||
// b must share the same backing array as p.data.
|
// b must be a suffix (tail) of p.data.
|
||||||
func (p *Parser) subsliceOffset(b []byte) int {
|
func (p *Parser) subsliceOffset(b []byte) int {
|
||||||
if len(b) == 0 {
|
// b is a suffix of p.data, so its offset is len(p.data) - len(b)
|
||||||
// Most callers pass suffix slices, so preserve EOF behavior.
|
return len(p.data) - len(b)
|
||||||
return len(p.data)
|
|
||||||
}
|
|
||||||
|
|
||||||
dataPtr := reflect.ValueOf(p.data).Pointer()
|
|
||||||
subPtr := reflect.ValueOf(b).Pointer()
|
|
||||||
|
|
||||||
offset := int(subPtr - dataPtr)
|
|
||||||
if offset < 0 || offset+len(b) > len(p.data) {
|
|
||||||
panic("subslice is not within parser input")
|
|
||||||
}
|
|
||||||
|
|
||||||
return offset
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw returns the slice corresponding to the bytes in the given range.
|
// Raw returns the slice corresponding to the bytes in the given range.
|
||||||
|
|||||||
Reference in New Issue
Block a user