From 6026159ccd8598a1d3f6070e113522ecf9a0fc3b Mon Sep 17 00:00:00 2001
From: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com>
Date: Sat, 28 May 2022 22:59:27 +0200
Subject: [PATCH 1/6] implement encoding.TextMarshaler and
encoding.TextUnmarshaler
---
version.go | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/version.go b/version.go
index 4283d39..55f09a1 100644
--- a/version.go
+++ b/version.go
@@ -55,8 +55,10 @@ func init() {
versionRegex = regexp.MustCompile("^" + semVerRegex + "$")
}
-const num string = "0123456789"
-const allowed string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-" + num
+const (
+ num string = "0123456789"
+ allowed string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-" + num
+)
// StrictNewVersion parses a given version and returns an instance of Version or
// an error if unable to parse the version. Only parses valid semantic versions.
@@ -267,7 +269,6 @@ func (v Version) Metadata() string {
// originalVPrefix returns the original 'v' prefix if any.
func (v Version) originalVPrefix() string {
-
// Note, only lowercase v is supported as a prefix by the parser.
if v.original != "" && v.original[:1] == "v" {
return v.original[:1]
@@ -436,6 +437,26 @@ func (v Version) MarshalJSON() ([]byte, error) {
return json.Marshal(v.String())
}
+// UnmarshalText implements the encoding.TextUnmarshaler interface.
+func (v *Version) UnmarshalText(text []byte) error {
+ temp, err := NewVersion(string(text))
+ if err != nil {
+ return err
+ }
+ v.major = temp.major
+ v.minor = temp.minor
+ v.patch = temp.patch
+ v.pre = temp.pre
+ v.metadata = temp.metadata
+ v.original = temp.original
+ return nil
+}
+
+// MarshalText implements the encoding.TextMarshaler interface.
+func (v Version) MarshalText() ([]byte, error) {
+ return []byte(v.String()), nil
+}
+
// Scan implements the SQL.Scanner interface.
func (v *Version) Scan(value interface{}) error {
var s string
@@ -470,7 +491,6 @@ func compareSegment(v, o uint64) int {
}
func comparePrerelease(v, o string) int {
-
// split the prelease versions by their part. The separator, per the spec,
// is a .
sparts := strings.Split(v, ".")
@@ -562,7 +582,6 @@ func comparePrePart(s, o string) int {
return 1
}
return -1
-
}
// Like strings.ContainsAny but does an only instead of any.
From 52f6efea7c5bb27df8b7ec12586756033811affd Mon Sep 17 00:00:00 2001
From: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com>
Date: Sat, 28 May 2022 22:59:44 +0200
Subject: [PATCH 2/6] test yaml (un)marshal
---
version_test.go | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/version_test.go b/version_test.go
index 0f690f4..58eecae 100644
--- a/version_test.go
+++ b/version_test.go
@@ -5,6 +5,10 @@ import (
"encoding/json"
"fmt"
"testing"
+
+ yamlGoccy "github.com/goccy/go-yaml"
+ yamlV2 "gopkg.in/yaml.v2"
+ yamlV3 "gopkg.in/yaml.v3"
)
func TestStrictNewVersion(t *testing.T) {
@@ -542,6 +546,69 @@ func TestJsonUnmarshal(t *testing.T) {
}
}
+type testStruct struct {
+ MyVersion *Version `yaml:"myVersion"`
+}
+
+func TestYAMLMarshal(t *testing.T) {
+ t.Parallel()
+
+ sVer := "1.1.1"
+ x, err := StrictNewVersion(sVer)
+ if err != nil {
+ t.Errorf("creating version: %s", err)
+ }
+
+ for i, marshal := range []func(interface{}) ([]byte, error){
+ yamlGoccy.Marshal,
+ yamlV2.Marshal,
+ yamlV3.Marshal,
+ } {
+ t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
+ t.Parallel()
+
+ out, err2 := marshal(testStruct{MyVersion: x})
+ if err2 != nil {
+ t.Errorf("Error marshaling version: %s", err2)
+ }
+
+ got := string(out)
+ want := fmt.Sprintf("myVersion: %s\n", sVer)
+ if got != want {
+ t.Errorf("Error marshaling unexpected marshaled content: got=%q want=%q", got, want)
+ }
+ })
+ }
+}
+
+func TestYAMLUnmarshal(t *testing.T) {
+ t.Parallel()
+
+ sVer := "1.1.1"
+
+ for i, unmarshal := range []func([]byte, interface{}) error{
+ yamlGoccy.Unmarshal,
+ yamlV2.Unmarshal,
+ yamlV3.Unmarshal,
+ } {
+ t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
+ t.Parallel()
+
+ ts := &testStruct{}
+ err := unmarshal([]byte(fmt.Sprintf("myVersion: %s\n", sVer)), ts)
+ if err != nil {
+ t.Errorf("Error unmarshaling version: %s", err)
+ }
+
+ got := ts.MyVersion.String()
+ want := sVer
+ if got != want {
+ t.Errorf("Error unmarshaling unexpected object content: got=%q want=%q", got, want)
+ }
+ })
+ }
+}
+
func TestSQLScanner(t *testing.T) {
sVer := "1.1.1"
x, err := StrictNewVersion(sVer)
From fbf6d4096bb8b1eea1778794977b78a19826aec1 Mon Sep 17 00:00:00 2001
From: Mark Rosemaker <48681726+MarkRosemaker@users.noreply.github.com>
Date: Sat, 28 May 2022 22:59:53 +0200
Subject: [PATCH 3/6] go mod
---
go.mod | 10 +
go.sum | 54 +
vendor/github.com/fatih/color/LICENSE.md | 20 +
vendor/github.com/fatih/color/README.md | 178 +
vendor/github.com/fatih/color/color.go | 618 ++
vendor/github.com/fatih/color/doc.go | 135 +
vendor/github.com/fatih/color/go.mod | 8 +
vendor/github.com/fatih/color/go.sum | 9 +
vendor/github.com/goccy/go-yaml/.codecov.yml | 31 +
vendor/github.com/goccy/go-yaml/CHANGELOG.md | 102 +
vendor/github.com/goccy/go-yaml/LICENSE | 21 +
vendor/github.com/goccy/go-yaml/Makefile | 15 +
vendor/github.com/goccy/go-yaml/README.md | 370 ++
vendor/github.com/goccy/go-yaml/ast/ast.go | 2162 +++++++
vendor/github.com/goccy/go-yaml/decode.go | 1584 +++++
vendor/github.com/goccy/go-yaml/encode.go | 733 +++
vendor/github.com/goccy/go-yaml/error.go | 54 +
vendor/github.com/goccy/go-yaml/go.mod | 10 +
vendor/github.com/goccy/go-yaml/go.sum | 41 +
.../goccy/go-yaml/internal/errors/error.go | 222 +
.../github.com/goccy/go-yaml/lexer/lexer.go | 23 +
vendor/github.com/goccy/go-yaml/option.go | 237 +
.../goccy/go-yaml/parser/context.go | 199 +
.../github.com/goccy/go-yaml/parser/parser.go | 671 ++
vendor/github.com/goccy/go-yaml/path.go | 794 +++
.../goccy/go-yaml/printer/printer.go | 352 ++
.../goccy/go-yaml/scanner/context.go | 201 +
.../goccy/go-yaml/scanner/scanner.go | 876 +++
.../github.com/goccy/go-yaml/stdlib_quote.go | 103 +
vendor/github.com/goccy/go-yaml/struct.go | 130 +
.../github.com/goccy/go-yaml/token/token.go | 1036 +++
vendor/github.com/goccy/go-yaml/validate.go | 13 +
vendor/github.com/goccy/go-yaml/yaml.go | 250 +
vendor/github.com/mattn/go-colorable/LICENSE | 21 +
.../github.com/mattn/go-colorable/README.md | 48 +
.../mattn/go-colorable/colorable_appengine.go | 38 +
.../mattn/go-colorable/colorable_others.go | 38 +
.../mattn/go-colorable/colorable_windows.go | 1047 +++
vendor/github.com/mattn/go-colorable/go.mod | 8 +
vendor/github.com/mattn/go-colorable/go.sum | 5 +
.../github.com/mattn/go-colorable/go.test.sh | 12 +
.../mattn/go-colorable/noncolorable.go | 57 +
vendor/github.com/mattn/go-isatty/LICENSE | 9 +
vendor/github.com/mattn/go-isatty/README.md | 50 +
vendor/github.com/mattn/go-isatty/doc.go | 2 +
vendor/github.com/mattn/go-isatty/go.mod | 5 +
vendor/github.com/mattn/go-isatty/go.sum | 2 +
vendor/github.com/mattn/go-isatty/go.test.sh | 12 +
.../github.com/mattn/go-isatty/isatty_bsd.go | 19 +
.../mattn/go-isatty/isatty_others.go | 16 +
.../mattn/go-isatty/isatty_plan9.go | 23 +
.../mattn/go-isatty/isatty_solaris.go | 21 +
.../mattn/go-isatty/isatty_tcgets.go | 19 +
.../mattn/go-isatty/isatty_windows.go | 125 +
vendor/golang.org/x/sys/AUTHORS | 3 +
vendor/golang.org/x/sys/CONTRIBUTORS | 3 +
vendor/golang.org/x/sys/LICENSE | 27 +
vendor/golang.org/x/sys/PATENTS | 22 +
.../sys/internal/unsafeheader/unsafeheader.go | 30 +
vendor/golang.org/x/sys/unix/.gitignore | 2 +
vendor/golang.org/x/sys/unix/README.md | 184 +
.../golang.org/x/sys/unix/affinity_linux.go | 86 +
vendor/golang.org/x/sys/unix/aliases.go | 15 +
vendor/golang.org/x/sys/unix/asm_aix_ppc64.s | 18 +
vendor/golang.org/x/sys/unix/asm_bsd_386.s | 29 +
vendor/golang.org/x/sys/unix/asm_bsd_amd64.s | 29 +
vendor/golang.org/x/sys/unix/asm_bsd_arm.s | 29 +
vendor/golang.org/x/sys/unix/asm_bsd_arm64.s | 29 +
vendor/golang.org/x/sys/unix/asm_linux_386.s | 66 +
.../golang.org/x/sys/unix/asm_linux_amd64.s | 58 +
vendor/golang.org/x/sys/unix/asm_linux_arm.s | 57 +
.../golang.org/x/sys/unix/asm_linux_arm64.s | 53 +
.../golang.org/x/sys/unix/asm_linux_loong64.s | 54 +
.../golang.org/x/sys/unix/asm_linux_mips64x.s | 57 +
.../golang.org/x/sys/unix/asm_linux_mipsx.s | 55 +
.../golang.org/x/sys/unix/asm_linux_ppc64x.s | 45 +
.../golang.org/x/sys/unix/asm_linux_riscv64.s | 49 +
.../golang.org/x/sys/unix/asm_linux_s390x.s | 57 +
.../x/sys/unix/asm_openbsd_mips64.s | 30 +
.../golang.org/x/sys/unix/asm_solaris_amd64.s | 18 +
vendor/golang.org/x/sys/unix/asm_zos_s390x.s | 426 ++
.../golang.org/x/sys/unix/bluetooth_linux.go | 36 +
vendor/golang.org/x/sys/unix/cap_freebsd.go | 196 +
vendor/golang.org/x/sys/unix/constants.go | 14 +
vendor/golang.org/x/sys/unix/dev_aix_ppc.go | 27 +
vendor/golang.org/x/sys/unix/dev_aix_ppc64.go | 29 +
vendor/golang.org/x/sys/unix/dev_darwin.go | 24 +
vendor/golang.org/x/sys/unix/dev_dragonfly.go | 30 +
vendor/golang.org/x/sys/unix/dev_freebsd.go | 30 +
vendor/golang.org/x/sys/unix/dev_linux.go | 42 +
vendor/golang.org/x/sys/unix/dev_netbsd.go | 29 +
vendor/golang.org/x/sys/unix/dev_openbsd.go | 29 +
vendor/golang.org/x/sys/unix/dev_zos.go | 29 +
vendor/golang.org/x/sys/unix/dirent.go | 103 +
vendor/golang.org/x/sys/unix/endian_big.go | 10 +
vendor/golang.org/x/sys/unix/endian_little.go | 10 +
vendor/golang.org/x/sys/unix/env_unix.go | 32 +
vendor/golang.org/x/sys/unix/epoll_zos.go | 221 +
.../x/sys/unix/errors_freebsd_386.go | 233 +
.../x/sys/unix/errors_freebsd_amd64.go | 233 +
.../x/sys/unix/errors_freebsd_arm.go | 226 +
.../x/sys/unix/errors_freebsd_arm64.go | 17 +
vendor/golang.org/x/sys/unix/fcntl.go | 37 +
vendor/golang.org/x/sys/unix/fcntl_darwin.go | 24 +
.../x/sys/unix/fcntl_linux_32bit.go | 14 +
vendor/golang.org/x/sys/unix/fdset.go | 30 +
vendor/golang.org/x/sys/unix/fstatfs_zos.go | 164 +
vendor/golang.org/x/sys/unix/gccgo.go | 60 +
vendor/golang.org/x/sys/unix/gccgo_c.c | 45 +
.../x/sys/unix/gccgo_linux_amd64.go | 21 +
vendor/golang.org/x/sys/unix/ifreq_linux.go | 142 +
vendor/golang.org/x/sys/unix/ioctl.go | 75 +
vendor/golang.org/x/sys/unix/ioctl_linux.go | 219 +
vendor/golang.org/x/sys/unix/ioctl_zos.go | 74 +
vendor/golang.org/x/sys/unix/mkall.sh | 231 +
vendor/golang.org/x/sys/unix/mkerrors.sh | 772 +++
vendor/golang.org/x/sys/unix/pagesize_unix.go | 16 +
.../golang.org/x/sys/unix/pledge_openbsd.go | 163 +
vendor/golang.org/x/sys/unix/ptrace_darwin.go | 12 +
vendor/golang.org/x/sys/unix/ptrace_ios.go | 12 +
vendor/golang.org/x/sys/unix/race.go | 31 +
vendor/golang.org/x/sys/unix/race0.go | 26 +
.../x/sys/unix/readdirent_getdents.go | 13 +
.../x/sys/unix/readdirent_getdirentries.go | 20 +
.../x/sys/unix/sockcmsg_dragonfly.go | 16 +
.../golang.org/x/sys/unix/sockcmsg_linux.go | 85 +
vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 93 +
.../x/sys/unix/sockcmsg_unix_other.go | 47 +
vendor/golang.org/x/sys/unix/str.go | 27 +
vendor/golang.org/x/sys/unix/syscall.go | 95 +
vendor/golang.org/x/sys/unix/syscall_aix.go | 551 ++
.../golang.org/x/sys/unix/syscall_aix_ppc.go | 54 +
.../x/sys/unix/syscall_aix_ppc64.go | 85 +
vendor/golang.org/x/sys/unix/syscall_bsd.go | 625 ++
.../x/sys/unix/syscall_darwin.1_12.go | 32 +
.../x/sys/unix/syscall_darwin.1_13.go | 108 +
.../golang.org/x/sys/unix/syscall_darwin.go | 733 +++
.../x/sys/unix/syscall_darwin_amd64.go | 51 +
.../x/sys/unix/syscall_darwin_arm64.go | 51 +
.../x/sys/unix/syscall_darwin_libSystem.go | 27 +
.../x/sys/unix/syscall_dragonfly.go | 544 ++
.../x/sys/unix/syscall_dragonfly_amd64.go | 57 +
.../golang.org/x/sys/unix/syscall_freebsd.go | 869 +++
.../x/sys/unix/syscall_freebsd_386.go | 67 +
.../x/sys/unix/syscall_freebsd_amd64.go | 67 +
.../x/sys/unix/syscall_freebsd_arm.go | 63 +
.../x/sys/unix/syscall_freebsd_arm64.go | 63 +
.../golang.org/x/sys/unix/syscall_illumos.go | 186 +
vendor/golang.org/x/sys/unix/syscall_linux.go | 2456 ++++++++
.../x/sys/unix/syscall_linux_386.go | 346 +
.../x/sys/unix/syscall_linux_alarm.go | 14 +
.../x/sys/unix/syscall_linux_amd64.go | 151 +
.../x/sys/unix/syscall_linux_amd64_gc.go | 13 +
.../x/sys/unix/syscall_linux_arm.go | 248 +
.../x/sys/unix/syscall_linux_arm64.go | 199 +
.../golang.org/x/sys/unix/syscall_linux_gc.go | 15 +
.../x/sys/unix/syscall_linux_gc_386.go | 17 +
.../x/sys/unix/syscall_linux_gc_arm.go | 14 +
.../x/sys/unix/syscall_linux_gccgo_386.go | 31 +
.../x/sys/unix/syscall_linux_gccgo_arm.go | 21 +
.../x/sys/unix/syscall_linux_loong64.go | 191 +
.../x/sys/unix/syscall_linux_mips64x.go | 195 +
.../x/sys/unix/syscall_linux_mipsx.go | 207 +
.../x/sys/unix/syscall_linux_ppc.go | 236 +
.../x/sys/unix/syscall_linux_ppc64x.go | 122 +
.../x/sys/unix/syscall_linux_riscv64.go | 183 +
.../x/sys/unix/syscall_linux_s390x.go | 302 +
.../x/sys/unix/syscall_linux_sparc64.go | 118 +
.../golang.org/x/sys/unix/syscall_netbsd.go | 609 ++
.../x/sys/unix/syscall_netbsd_386.go | 38 +
.../x/sys/unix/syscall_netbsd_amd64.go | 38 +
.../x/sys/unix/syscall_netbsd_arm.go | 38 +
.../x/sys/unix/syscall_netbsd_arm64.go | 38 +
.../golang.org/x/sys/unix/syscall_openbsd.go | 389 ++
.../x/sys/unix/syscall_openbsd_386.go | 42 +
.../x/sys/unix/syscall_openbsd_amd64.go | 42 +
.../x/sys/unix/syscall_openbsd_arm.go | 42 +
.../x/sys/unix/syscall_openbsd_arm64.go | 42 +
.../x/sys/unix/syscall_openbsd_mips64.go | 35 +
.../golang.org/x/sys/unix/syscall_solaris.go | 1004 +++
.../x/sys/unix/syscall_solaris_amd64.go | 28 +
vendor/golang.org/x/sys/unix/syscall_unix.go | 486 ++
.../golang.org/x/sys/unix/syscall_unix_gc.go | 18 +
.../x/sys/unix/syscall_unix_gc_ppc64x.go | 25 +
.../x/sys/unix/syscall_zos_s390x.go | 1823 ++++++
vendor/golang.org/x/sys/unix/sysvshm_linux.go | 21 +
vendor/golang.org/x/sys/unix/sysvshm_unix.go | 61 +
.../x/sys/unix/sysvshm_unix_other.go | 14 +
vendor/golang.org/x/sys/unix/timestruct.go | 77 +
.../golang.org/x/sys/unix/unveil_openbsd.go | 42 +
vendor/golang.org/x/sys/unix/xattr_bsd.go | 241 +
.../golang.org/x/sys/unix/zerrors_aix_ppc.go | 1385 ++++
.../x/sys/unix/zerrors_aix_ppc64.go | 1386 ++++
.../x/sys/unix/zerrors_darwin_amd64.go | 1892 ++++++
.../x/sys/unix/zerrors_darwin_arm64.go | 1892 ++++++
.../x/sys/unix/zerrors_dragonfly_amd64.go | 1738 +++++
.../x/sys/unix/zerrors_freebsd_386.go | 1948 ++++++
.../x/sys/unix/zerrors_freebsd_amd64.go | 1947 ++++++
.../x/sys/unix/zerrors_freebsd_arm.go | 1846 ++++++
.../x/sys/unix/zerrors_freebsd_arm64.go | 1948 ++++++
vendor/golang.org/x/sys/unix/zerrors_linux.go | 3084 +++++++++
.../x/sys/unix/zerrors_linux_386.go | 826 +++
.../x/sys/unix/zerrors_linux_amd64.go | 826 +++
.../x/sys/unix/zerrors_linux_arm.go | 832 +++
.../x/sys/unix/zerrors_linux_arm64.go | 823 +++
.../x/sys/unix/zerrors_linux_loong64.go | 818 +++
.../x/sys/unix/zerrors_linux_mips.go | 833 +++
.../x/sys/unix/zerrors_linux_mips64.go | 833 +++
.../x/sys/unix/zerrors_linux_mips64le.go | 833 +++
.../x/sys/unix/zerrors_linux_mipsle.go | 833 +++
.../x/sys/unix/zerrors_linux_ppc.go | 885 +++
.../x/sys/unix/zerrors_linux_ppc64.go | 889 +++
.../x/sys/unix/zerrors_linux_ppc64le.go | 889 +++
.../x/sys/unix/zerrors_linux_riscv64.go | 813 +++
.../x/sys/unix/zerrors_linux_s390x.go | 888 +++
.../x/sys/unix/zerrors_linux_sparc64.go | 883 +++
.../x/sys/unix/zerrors_netbsd_386.go | 1780 ++++++
.../x/sys/unix/zerrors_netbsd_amd64.go | 1770 ++++++
.../x/sys/unix/zerrors_netbsd_arm.go | 1759 ++++++
.../x/sys/unix/zerrors_netbsd_arm64.go | 1770 ++++++
.../x/sys/unix/zerrors_openbsd_386.go | 1668 +++++
.../x/sys/unix/zerrors_openbsd_amd64.go | 1775 ++++++
.../x/sys/unix/zerrors_openbsd_arm.go | 1670 +++++
.../x/sys/unix/zerrors_openbsd_arm64.go | 1798 ++++++
.../x/sys/unix/zerrors_openbsd_mips64.go | 1863 ++++++
.../x/sys/unix/zerrors_solaris_amd64.go | 1557 +++++
.../x/sys/unix/zerrors_zos_s390x.go | 860 +++
.../x/sys/unix/zptrace_armnn_linux.go | 42 +
.../x/sys/unix/zptrace_linux_arm64.go | 17 +
.../x/sys/unix/zptrace_mipsnn_linux.go | 51 +
.../x/sys/unix/zptrace_mipsnnle_linux.go | 51 +
.../x/sys/unix/zptrace_x86_linux.go | 81 +
.../golang.org/x/sys/unix/zsyscall_aix_ppc.go | 1485 +++++
.../x/sys/unix/zsyscall_aix_ppc64.go | 1443 +++++
.../x/sys/unix/zsyscall_aix_ppc64_gc.go | 1192 ++++
.../x/sys/unix/zsyscall_aix_ppc64_gccgo.go | 1070 ++++
.../x/sys/unix/zsyscall_darwin_amd64.1_13.go | 40 +
.../x/sys/unix/zsyscall_darwin_amd64.1_13.s | 25 +
.../x/sys/unix/zsyscall_darwin_amd64.go | 2519 ++++++++
.../x/sys/unix/zsyscall_darwin_amd64.s | 889 +++
.../x/sys/unix/zsyscall_darwin_arm64.1_13.go | 40 +
.../x/sys/unix/zsyscall_darwin_arm64.1_13.s | 25 +
.../x/sys/unix/zsyscall_darwin_arm64.go | 2519 ++++++++
.../x/sys/unix/zsyscall_darwin_arm64.s | 889 +++
.../x/sys/unix/zsyscall_dragonfly_amd64.go | 1679 +++++
.../x/sys/unix/zsyscall_freebsd_386.go | 2016 ++++++
.../x/sys/unix/zsyscall_freebsd_amd64.go | 2016 ++++++
.../x/sys/unix/zsyscall_freebsd_arm.go | 2016 ++++++
.../x/sys/unix/zsyscall_freebsd_arm64.go | 2016 ++++++
.../x/sys/unix/zsyscall_illumos_amd64.go | 128 +
.../golang.org/x/sys/unix/zsyscall_linux.go | 2153 +++++++
.../x/sys/unix/zsyscall_linux_386.go | 537 ++
.../x/sys/unix/zsyscall_linux_amd64.go | 704 +++
.../x/sys/unix/zsyscall_linux_arm.go | 652 ++
.../x/sys/unix/zsyscall_linux_arm64.go | 603 ++
.../x/sys/unix/zsyscall_linux_loong64.go | 552 ++
.../x/sys/unix/zsyscall_linux_mips.go | 704 +++
.../x/sys/unix/zsyscall_linux_mips64.go | 698 ++
.../x/sys/unix/zsyscall_linux_mips64le.go | 687 ++
.../x/sys/unix/zsyscall_linux_mipsle.go | 704 +++
.../x/sys/unix/zsyscall_linux_ppc.go | 709 +++
.../x/sys/unix/zsyscall_linux_ppc64.go | 755 +++
.../x/sys/unix/zsyscall_linux_ppc64le.go | 755 +++
.../x/sys/unix/zsyscall_linux_riscv64.go | 572 ++
.../x/sys/unix/zsyscall_linux_s390x.go | 546 ++
.../x/sys/unix/zsyscall_linux_sparc64.go | 699 +++
.../x/sys/unix/zsyscall_netbsd_386.go | 1850 ++++++
.../x/sys/unix/zsyscall_netbsd_amd64.go | 1850 ++++++
.../x/sys/unix/zsyscall_netbsd_arm.go | 1850 ++++++
.../x/sys/unix/zsyscall_netbsd_arm64.go | 1850 ++++++
.../x/sys/unix/zsyscall_openbsd_386.go | 1693 +++++
.../x/sys/unix/zsyscall_openbsd_amd64.go | 1693 +++++
.../x/sys/unix/zsyscall_openbsd_arm.go | 1693 +++++
.../x/sys/unix/zsyscall_openbsd_arm64.go | 1693 +++++
.../x/sys/unix/zsyscall_openbsd_mips64.go | 1693 +++++
.../x/sys/unix/zsyscall_solaris_amd64.go | 2053 ++++++
.../x/sys/unix/zsyscall_zos_s390x.go | 1255 ++++
.../x/sys/unix/zsysctl_openbsd_386.go | 274 +
.../x/sys/unix/zsysctl_openbsd_amd64.go | 272 +
.../x/sys/unix/zsysctl_openbsd_arm.go | 274 +
.../x/sys/unix/zsysctl_openbsd_arm64.go | 276 +
.../x/sys/unix/zsysctl_openbsd_mips64.go | 280 +
.../x/sys/unix/zsysnum_darwin_amd64.go | 440 ++
.../x/sys/unix/zsysnum_darwin_arm64.go | 438 ++
.../x/sys/unix/zsysnum_dragonfly_amd64.go | 317 +
.../x/sys/unix/zsysnum_freebsd_386.go | 397 ++
.../x/sys/unix/zsysnum_freebsd_amd64.go | 397 ++
.../x/sys/unix/zsysnum_freebsd_arm.go | 397 ++
.../x/sys/unix/zsysnum_freebsd_arm64.go | 397 ++
.../x/sys/unix/zsysnum_linux_386.go | 450 ++
.../x/sys/unix/zsysnum_linux_amd64.go | 372 ++
.../x/sys/unix/zsysnum_linux_arm.go | 414 ++
.../x/sys/unix/zsysnum_linux_arm64.go | 317 +
.../x/sys/unix/zsysnum_linux_loong64.go | 313 +
.../x/sys/unix/zsysnum_linux_mips.go | 434 ++
.../x/sys/unix/zsysnum_linux_mips64.go | 364 ++
.../x/sys/unix/zsysnum_linux_mips64le.go | 364 ++
.../x/sys/unix/zsysnum_linux_mipsle.go | 434 ++
.../x/sys/unix/zsysnum_linux_ppc.go | 441 ++
.../x/sys/unix/zsysnum_linux_ppc64.go | 413 ++
.../x/sys/unix/zsysnum_linux_ppc64le.go | 413 ++
.../x/sys/unix/zsysnum_linux_riscv64.go | 315 +
.../x/sys/unix/zsysnum_linux_s390x.go | 378 ++
.../x/sys/unix/zsysnum_linux_sparc64.go | 392 ++
.../x/sys/unix/zsysnum_netbsd_386.go | 275 +
.../x/sys/unix/zsysnum_netbsd_amd64.go | 275 +
.../x/sys/unix/zsysnum_netbsd_arm.go | 275 +
.../x/sys/unix/zsysnum_netbsd_arm64.go | 275 +
.../x/sys/unix/zsysnum_openbsd_386.go | 219 +
.../x/sys/unix/zsysnum_openbsd_amd64.go | 219 +
.../x/sys/unix/zsysnum_openbsd_arm.go | 219 +
.../x/sys/unix/zsysnum_openbsd_arm64.go | 218 +
.../x/sys/unix/zsysnum_openbsd_mips64.go | 221 +
.../x/sys/unix/zsysnum_zos_s390x.go | 2670 ++++++++
.../golang.org/x/sys/unix/ztypes_aix_ppc.go | 354 ++
.../golang.org/x/sys/unix/ztypes_aix_ppc64.go | 358 ++
.../x/sys/unix/ztypes_darwin_amd64.go | 768 +++
.../x/sys/unix/ztypes_darwin_arm64.go | 768 +++
.../x/sys/unix/ztypes_dragonfly_amd64.go | 474 ++
.../x/sys/unix/ztypes_freebsd_386.go | 723 +++
.../x/sys/unix/ztypes_freebsd_amd64.go | 726 +++
.../x/sys/unix/ztypes_freebsd_arm.go | 707 +++
.../x/sys/unix/ztypes_freebsd_arm64.go | 704 +++
.../x/sys/unix/ztypes_illumos_amd64.go | 42 +
vendor/golang.org/x/sys/unix/ztypes_linux.go | 5590 +++++++++++++++++
.../golang.org/x/sys/unix/ztypes_linux_386.go | 683 ++
.../x/sys/unix/ztypes_linux_amd64.go | 699 +++
.../golang.org/x/sys/unix/ztypes_linux_arm.go | 678 ++
.../x/sys/unix/ztypes_linux_arm64.go | 678 ++
.../x/sys/unix/ztypes_linux_loong64.go | 679 ++
.../x/sys/unix/ztypes_linux_mips.go | 683 ++
.../x/sys/unix/ztypes_linux_mips64.go | 681 ++
.../x/sys/unix/ztypes_linux_mips64le.go | 681 ++
.../x/sys/unix/ztypes_linux_mipsle.go | 683 ++
.../golang.org/x/sys/unix/ztypes_linux_ppc.go | 691 ++
.../x/sys/unix/ztypes_linux_ppc64.go | 687 ++
.../x/sys/unix/ztypes_linux_ppc64le.go | 687 ++
.../x/sys/unix/ztypes_linux_riscv64.go | 706 +++
.../x/sys/unix/ztypes_linux_s390x.go | 701 +++
.../x/sys/unix/ztypes_linux_sparc64.go | 682 ++
.../x/sys/unix/ztypes_netbsd_386.go | 502 ++
.../x/sys/unix/ztypes_netbsd_amd64.go | 510 ++
.../x/sys/unix/ztypes_netbsd_arm.go | 507 ++
.../x/sys/unix/ztypes_netbsd_arm64.go | 510 ++
.../x/sys/unix/ztypes_openbsd_386.go | 574 ++
.../x/sys/unix/ztypes_openbsd_amd64.go | 574 ++
.../x/sys/unix/ztypes_openbsd_arm.go | 575 ++
.../x/sys/unix/ztypes_openbsd_arm64.go | 568 ++
.../x/sys/unix/ztypes_openbsd_mips64.go | 568 ++
.../x/sys/unix/ztypes_solaris_amd64.go | 482 ++
.../golang.org/x/sys/unix/ztypes_zos_s390x.go | 406 ++
vendor/golang.org/x/xerrors/LICENSE | 27 +
vendor/golang.org/x/xerrors/PATENTS | 22 +
vendor/golang.org/x/xerrors/README | 2 +
vendor/golang.org/x/xerrors/adaptor.go | 193 +
vendor/golang.org/x/xerrors/codereview.cfg | 1 +
vendor/golang.org/x/xerrors/doc.go | 23 +
vendor/golang.org/x/xerrors/errors.go | 33 +
vendor/golang.org/x/xerrors/fmt.go | 189 +
vendor/golang.org/x/xerrors/format.go | 34 +
vendor/golang.org/x/xerrors/frame.go | 56 +
vendor/golang.org/x/xerrors/go.mod | 3 +
.../golang.org/x/xerrors/internal/internal.go | 8 +
vendor/golang.org/x/xerrors/wrap.go | 112 +
vendor/gopkg.in/yaml.v2/.travis.yml | 17 +
vendor/gopkg.in/yaml.v2/LICENSE | 201 +
vendor/gopkg.in/yaml.v2/LICENSE.libyaml | 31 +
vendor/gopkg.in/yaml.v2/NOTICE | 13 +
vendor/gopkg.in/yaml.v2/README.md | 133 +
vendor/gopkg.in/yaml.v2/apic.go | 744 +++
vendor/gopkg.in/yaml.v2/decode.go | 815 +++
vendor/gopkg.in/yaml.v2/emitterc.go | 1685 +++++
vendor/gopkg.in/yaml.v2/encode.go | 390 ++
vendor/gopkg.in/yaml.v2/go.mod | 5 +
vendor/gopkg.in/yaml.v2/parserc.go | 1095 ++++
vendor/gopkg.in/yaml.v2/readerc.go | 412 ++
vendor/gopkg.in/yaml.v2/resolve.go | 258 +
vendor/gopkg.in/yaml.v2/scannerc.go | 2711 ++++++++
vendor/gopkg.in/yaml.v2/sorter.go | 113 +
vendor/gopkg.in/yaml.v2/writerc.go | 26 +
vendor/gopkg.in/yaml.v2/yaml.go | 478 ++
vendor/gopkg.in/yaml.v2/yamlh.go | 739 +++
vendor/gopkg.in/yaml.v2/yamlprivateh.go | 173 +
vendor/gopkg.in/yaml.v3/LICENSE | 50 +
vendor/gopkg.in/yaml.v3/NOTICE | 13 +
vendor/gopkg.in/yaml.v3/README.md | 150 +
vendor/gopkg.in/yaml.v3/apic.go | 747 +++
vendor/gopkg.in/yaml.v3/decode.go | 1000 +++
vendor/gopkg.in/yaml.v3/emitterc.go | 2020 ++++++
vendor/gopkg.in/yaml.v3/encode.go | 577 ++
vendor/gopkg.in/yaml.v3/go.mod | 5 +
vendor/gopkg.in/yaml.v3/parserc.go | 1258 ++++
vendor/gopkg.in/yaml.v3/readerc.go | 434 ++
vendor/gopkg.in/yaml.v3/resolve.go | 326 +
vendor/gopkg.in/yaml.v3/scannerc.go | 3038 +++++++++
vendor/gopkg.in/yaml.v3/sorter.go | 134 +
vendor/gopkg.in/yaml.v3/writerc.go | 48 +
vendor/gopkg.in/yaml.v3/yaml.go | 698 ++
vendor/gopkg.in/yaml.v3/yamlh.go | 807 +++
vendor/gopkg.in/yaml.v3/yamlprivateh.go | 198 +
vendor/modules.txt | 25 +
401 files changed, 200929 insertions(+)
create mode 100644 go.sum
create mode 100644 vendor/github.com/fatih/color/LICENSE.md
create mode 100644 vendor/github.com/fatih/color/README.md
create mode 100644 vendor/github.com/fatih/color/color.go
create mode 100644 vendor/github.com/fatih/color/doc.go
create mode 100644 vendor/github.com/fatih/color/go.mod
create mode 100644 vendor/github.com/fatih/color/go.sum
create mode 100644 vendor/github.com/goccy/go-yaml/.codecov.yml
create mode 100644 vendor/github.com/goccy/go-yaml/CHANGELOG.md
create mode 100644 vendor/github.com/goccy/go-yaml/LICENSE
create mode 100644 vendor/github.com/goccy/go-yaml/Makefile
create mode 100644 vendor/github.com/goccy/go-yaml/README.md
create mode 100644 vendor/github.com/goccy/go-yaml/ast/ast.go
create mode 100644 vendor/github.com/goccy/go-yaml/decode.go
create mode 100644 vendor/github.com/goccy/go-yaml/encode.go
create mode 100644 vendor/github.com/goccy/go-yaml/error.go
create mode 100644 vendor/github.com/goccy/go-yaml/go.mod
create mode 100644 vendor/github.com/goccy/go-yaml/go.sum
create mode 100644 vendor/github.com/goccy/go-yaml/internal/errors/error.go
create mode 100644 vendor/github.com/goccy/go-yaml/lexer/lexer.go
create mode 100644 vendor/github.com/goccy/go-yaml/option.go
create mode 100644 vendor/github.com/goccy/go-yaml/parser/context.go
create mode 100644 vendor/github.com/goccy/go-yaml/parser/parser.go
create mode 100644 vendor/github.com/goccy/go-yaml/path.go
create mode 100644 vendor/github.com/goccy/go-yaml/printer/printer.go
create mode 100644 vendor/github.com/goccy/go-yaml/scanner/context.go
create mode 100644 vendor/github.com/goccy/go-yaml/scanner/scanner.go
create mode 100644 vendor/github.com/goccy/go-yaml/stdlib_quote.go
create mode 100644 vendor/github.com/goccy/go-yaml/struct.go
create mode 100644 vendor/github.com/goccy/go-yaml/token/token.go
create mode 100644 vendor/github.com/goccy/go-yaml/validate.go
create mode 100644 vendor/github.com/goccy/go-yaml/yaml.go
create mode 100644 vendor/github.com/mattn/go-colorable/LICENSE
create mode 100644 vendor/github.com/mattn/go-colorable/README.md
create mode 100644 vendor/github.com/mattn/go-colorable/colorable_appengine.go
create mode 100644 vendor/github.com/mattn/go-colorable/colorable_others.go
create mode 100644 vendor/github.com/mattn/go-colorable/colorable_windows.go
create mode 100644 vendor/github.com/mattn/go-colorable/go.mod
create mode 100644 vendor/github.com/mattn/go-colorable/go.sum
create mode 100644 vendor/github.com/mattn/go-colorable/go.test.sh
create mode 100644 vendor/github.com/mattn/go-colorable/noncolorable.go
create mode 100644 vendor/github.com/mattn/go-isatty/LICENSE
create mode 100644 vendor/github.com/mattn/go-isatty/README.md
create mode 100644 vendor/github.com/mattn/go-isatty/doc.go
create mode 100644 vendor/github.com/mattn/go-isatty/go.mod
create mode 100644 vendor/github.com/mattn/go-isatty/go.sum
create mode 100644 vendor/github.com/mattn/go-isatty/go.test.sh
create mode 100644 vendor/github.com/mattn/go-isatty/isatty_bsd.go
create mode 100644 vendor/github.com/mattn/go-isatty/isatty_others.go
create mode 100644 vendor/github.com/mattn/go-isatty/isatty_plan9.go
create mode 100644 vendor/github.com/mattn/go-isatty/isatty_solaris.go
create mode 100644 vendor/github.com/mattn/go-isatty/isatty_tcgets.go
create mode 100644 vendor/github.com/mattn/go-isatty/isatty_windows.go
create mode 100644 vendor/golang.org/x/sys/AUTHORS
create mode 100644 vendor/golang.org/x/sys/CONTRIBUTORS
create mode 100644 vendor/golang.org/x/sys/LICENSE
create mode 100644 vendor/golang.org/x/sys/PATENTS
create mode 100644 vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go
create mode 100644 vendor/golang.org/x/sys/unix/.gitignore
create mode 100644 vendor/golang.org/x/sys/unix/README.md
create mode 100644 vendor/golang.org/x/sys/unix/affinity_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/aliases.go
create mode 100644 vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_bsd_386.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_bsd_amd64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_bsd_arm.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_bsd_arm64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_386.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_amd64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_arm.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_arm64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_loong64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_s390x.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
create mode 100644 vendor/golang.org/x/sys/unix/asm_zos_s390x.s
create mode 100644 vendor/golang.org/x/sys/unix/bluetooth_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/cap_freebsd.go
create mode 100644 vendor/golang.org/x/sys/unix/constants.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_aix_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_darwin.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_dragonfly.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_freebsd.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_netbsd.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_openbsd.go
create mode 100644 vendor/golang.org/x/sys/unix/dev_zos.go
create mode 100644 vendor/golang.org/x/sys/unix/dirent.go
create mode 100644 vendor/golang.org/x/sys/unix/endian_big.go
create mode 100644 vendor/golang.org/x/sys/unix/endian_little.go
create mode 100644 vendor/golang.org/x/sys/unix/env_unix.go
create mode 100644 vendor/golang.org/x/sys/unix/epoll_zos.go
create mode 100644 vendor/golang.org/x/sys/unix/errors_freebsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/errors_freebsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/errors_freebsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/fcntl.go
create mode 100644 vendor/golang.org/x/sys/unix/fcntl_darwin.go
create mode 100644 vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
create mode 100644 vendor/golang.org/x/sys/unix/fdset.go
create mode 100644 vendor/golang.org/x/sys/unix/fstatfs_zos.go
create mode 100644 vendor/golang.org/x/sys/unix/gccgo.go
create mode 100644 vendor/golang.org/x/sys/unix/gccgo_c.c
create mode 100644 vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ifreq_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/ioctl.go
create mode 100644 vendor/golang.org/x/sys/unix/ioctl_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/ioctl_zos.go
create mode 100644 vendor/golang.org/x/sys/unix/mkall.sh
create mode 100644 vendor/golang.org/x/sys/unix/mkerrors.sh
create mode 100644 vendor/golang.org/x/sys/unix/pagesize_unix.go
create mode 100644 vendor/golang.org/x/sys/unix/pledge_openbsd.go
create mode 100644 vendor/golang.org/x/sys/unix/ptrace_darwin.go
create mode 100644 vendor/golang.org/x/sys/unix/ptrace_ios.go
create mode 100644 vendor/golang.org/x/sys/unix/race.go
create mode 100644 vendor/golang.org/x/sys/unix/race0.go
create mode 100644 vendor/golang.org/x/sys/unix/readdirent_getdents.go
create mode 100644 vendor/golang.org/x/sys/unix/readdirent_getdirentries.go
create mode 100644 vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go
create mode 100644 vendor/golang.org/x/sys/unix/sockcmsg_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/sockcmsg_unix.go
create mode 100644 vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
create mode 100644 vendor/golang.org/x/sys/unix/str.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_aix.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_aix_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_bsd.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_dragonfly.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_illumos.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_386.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_alarm.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_gc.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_loong64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_solaris.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_unix.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_unix_gc.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/sysvshm_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/sysvshm_unix.go
create mode 100644 vendor/golang.org/x/sys/unix/sysvshm_unix_other.go
create mode 100644 vendor/golang.org/x/sys/unix/timestruct.go
create mode 100644 vendor/golang.org/x/sys/unix/unveil_openbsd.go
create mode 100644 vendor/golang.org/x/sys/unix/xattr_bsd.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/zptrace_linux_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/zptrace_x86_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_zos_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_386.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_mips.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_arm64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_mips64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go
create mode 100644 vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go
create mode 100644 vendor/golang.org/x/xerrors/LICENSE
create mode 100644 vendor/golang.org/x/xerrors/PATENTS
create mode 100644 vendor/golang.org/x/xerrors/README
create mode 100644 vendor/golang.org/x/xerrors/adaptor.go
create mode 100644 vendor/golang.org/x/xerrors/codereview.cfg
create mode 100644 vendor/golang.org/x/xerrors/doc.go
create mode 100644 vendor/golang.org/x/xerrors/errors.go
create mode 100644 vendor/golang.org/x/xerrors/fmt.go
create mode 100644 vendor/golang.org/x/xerrors/format.go
create mode 100644 vendor/golang.org/x/xerrors/frame.go
create mode 100644 vendor/golang.org/x/xerrors/go.mod
create mode 100644 vendor/golang.org/x/xerrors/internal/internal.go
create mode 100644 vendor/golang.org/x/xerrors/wrap.go
create mode 100644 vendor/gopkg.in/yaml.v2/.travis.yml
create mode 100644 vendor/gopkg.in/yaml.v2/LICENSE
create mode 100644 vendor/gopkg.in/yaml.v2/LICENSE.libyaml
create mode 100644 vendor/gopkg.in/yaml.v2/NOTICE
create mode 100644 vendor/gopkg.in/yaml.v2/README.md
create mode 100644 vendor/gopkg.in/yaml.v2/apic.go
create mode 100644 vendor/gopkg.in/yaml.v2/decode.go
create mode 100644 vendor/gopkg.in/yaml.v2/emitterc.go
create mode 100644 vendor/gopkg.in/yaml.v2/encode.go
create mode 100644 vendor/gopkg.in/yaml.v2/go.mod
create mode 100644 vendor/gopkg.in/yaml.v2/parserc.go
create mode 100644 vendor/gopkg.in/yaml.v2/readerc.go
create mode 100644 vendor/gopkg.in/yaml.v2/resolve.go
create mode 100644 vendor/gopkg.in/yaml.v2/scannerc.go
create mode 100644 vendor/gopkg.in/yaml.v2/sorter.go
create mode 100644 vendor/gopkg.in/yaml.v2/writerc.go
create mode 100644 vendor/gopkg.in/yaml.v2/yaml.go
create mode 100644 vendor/gopkg.in/yaml.v2/yamlh.go
create mode 100644 vendor/gopkg.in/yaml.v2/yamlprivateh.go
create mode 100644 vendor/gopkg.in/yaml.v3/LICENSE
create mode 100644 vendor/gopkg.in/yaml.v3/NOTICE
create mode 100644 vendor/gopkg.in/yaml.v3/README.md
create mode 100644 vendor/gopkg.in/yaml.v3/apic.go
create mode 100644 vendor/gopkg.in/yaml.v3/decode.go
create mode 100644 vendor/gopkg.in/yaml.v3/emitterc.go
create mode 100644 vendor/gopkg.in/yaml.v3/encode.go
create mode 100644 vendor/gopkg.in/yaml.v3/go.mod
create mode 100644 vendor/gopkg.in/yaml.v3/parserc.go
create mode 100644 vendor/gopkg.in/yaml.v3/readerc.go
create mode 100644 vendor/gopkg.in/yaml.v3/resolve.go
create mode 100644 vendor/gopkg.in/yaml.v3/scannerc.go
create mode 100644 vendor/gopkg.in/yaml.v3/sorter.go
create mode 100644 vendor/gopkg.in/yaml.v3/writerc.go
create mode 100644 vendor/gopkg.in/yaml.v3/yaml.go
create mode 100644 vendor/gopkg.in/yaml.v3/yamlh.go
create mode 100644 vendor/gopkg.in/yaml.v3/yamlprivateh.go
create mode 100644 vendor/modules.txt
diff --git a/go.mod b/go.mod
index 658233c..a361c5a 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,13 @@
module github.com/Masterminds/semver/v3
go 1.12
+
+require (
+ github.com/fatih/color v1.13.0 // indirect
+ github.com/goccy/go-yaml v1.9.5
+ github.com/mattn/go-colorable v0.1.12 // indirect
+ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
+ golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
+ gopkg.in/yaml.v2 v2.4.0
+ gopkg.in/yaml.v3 v3.0.1
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..1542340
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,54 @@
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
+github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
+github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
+github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
+github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
+github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
+github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
+github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
+github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
+github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
+github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
+github.com/goccy/go-yaml v1.9.5 h1:Eh/+3uk9kLxG4koCX6lRMAPS1OaMSAi+FJcya0INdB0=
+github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
+github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
+github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
+github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
+github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
+github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618=
+golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/vendor/github.com/fatih/color/LICENSE.md b/vendor/github.com/fatih/color/LICENSE.md
new file mode 100644
index 0000000..25fdaf6
--- /dev/null
+++ b/vendor/github.com/fatih/color/LICENSE.md
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Fatih Arslan
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/fatih/color/README.md b/vendor/github.com/fatih/color/README.md
new file mode 100644
index 0000000..5152bf5
--- /dev/null
+++ b/vendor/github.com/fatih/color/README.md
@@ -0,0 +1,178 @@
+# color [![](https://github.com/fatih/color/workflows/build/badge.svg)](https://github.com/fatih/color/actions) [![PkgGoDev](https://pkg.go.dev/badge/github.com/fatih/color)](https://pkg.go.dev/github.com/fatih/color)
+
+Color lets you use colorized outputs in terms of [ANSI Escape
+Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It
+has support for Windows too! The API can be used in several ways, pick one that
+suits you.
+
+![Color](https://user-images.githubusercontent.com/438920/96832689-03b3e000-13f4-11eb-9803-46f4c4de3406.jpg)
+
+
+## Install
+
+```bash
+go get github.com/fatih/color
+```
+
+## Examples
+
+### Standard colors
+
+```go
+// Print with default helper functions
+color.Cyan("Prints text in cyan.")
+
+// A newline will be appended automatically
+color.Blue("Prints %s in blue.", "text")
+
+// These are using the default foreground colors
+color.Red("We have red")
+color.Magenta("And many others ..")
+
+```
+
+### Mix and reuse colors
+
+```go
+// Create a new color object
+c := color.New(color.FgCyan).Add(color.Underline)
+c.Println("Prints cyan text with an underline.")
+
+// Or just add them to New()
+d := color.New(color.FgCyan, color.Bold)
+d.Printf("This prints bold cyan %s\n", "too!.")
+
+// Mix up foreground and background colors, create new mixes!
+red := color.New(color.FgRed)
+
+boldRed := red.Add(color.Bold)
+boldRed.Println("This will print text in bold red.")
+
+whiteBackground := red.Add(color.BgWhite)
+whiteBackground.Println("Red text with white background.")
+```
+
+### Use your own output (io.Writer)
+
+```go
+// Use your own io.Writer output
+color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
+
+blue := color.New(color.FgBlue)
+blue.Fprint(writer, "This will print text in blue.")
+```
+
+### Custom print functions (PrintFunc)
+
+```go
+// Create a custom print function for convenience
+red := color.New(color.FgRed).PrintfFunc()
+red("Warning")
+red("Error: %s", err)
+
+// Mix up multiple attributes
+notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
+notice("Don't forget this...")
+```
+
+### Custom fprint functions (FprintFunc)
+
+```go
+blue := color.New(color.FgBlue).FprintfFunc()
+blue(myWriter, "important notice: %s", stars)
+
+// Mix up with multiple attributes
+success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
+success(myWriter, "Don't forget this...")
+```
+
+### Insert into noncolor strings (SprintFunc)
+
+```go
+// Create SprintXxx functions to mix strings with other non-colorized strings:
+yellow := color.New(color.FgYellow).SprintFunc()
+red := color.New(color.FgRed).SprintFunc()
+fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error"))
+
+info := color.New(color.FgWhite, color.BgGreen).SprintFunc()
+fmt.Printf("This %s rocks!\n", info("package"))
+
+// Use helper functions
+fmt.Println("This", color.RedString("warning"), "should be not neglected.")
+fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.")
+
+// Windows supported too! Just don't forget to change the output to color.Output
+fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
+```
+
+### Plug into existing code
+
+```go
+// Use handy standard colors
+color.Set(color.FgYellow)
+
+fmt.Println("Existing text will now be in yellow")
+fmt.Printf("This one %s\n", "too")
+
+color.Unset() // Don't forget to unset
+
+// You can mix up parameters
+color.Set(color.FgMagenta, color.Bold)
+defer color.Unset() // Use it in your function
+
+fmt.Println("All text will now be bold magenta.")
+```
+
+### Disable/Enable color
+
+There might be a case where you want to explicitly disable/enable color output. the
+`go-isatty` package will automatically disable color output for non-tty output streams
+(for example if the output were piped directly to `less`).
+
+The `color` package also disables color output if the [`NO_COLOR`](https://no-color.org) environment
+variable is set (regardless of its value).
+
+`Color` has support to disable/enable colors programatically both globally and
+for single color definitions. For example suppose you have a CLI app and a
+`--no-color` bool flag. You can easily disable the color output with:
+
+```go
+var flagNoColor = flag.Bool("no-color", false, "Disable color output")
+
+if *flagNoColor {
+ color.NoColor = true // disables colorized output
+}
+```
+
+It also has support for single color definitions (local). You can
+disable/enable color output on the fly:
+
+```go
+c := color.New(color.FgCyan)
+c.Println("Prints cyan text")
+
+c.DisableColor()
+c.Println("This is printed without any color")
+
+c.EnableColor()
+c.Println("This prints again cyan...")
+```
+
+## GitHub Actions
+
+To output color in GitHub Actions (or other CI systems that support ANSI colors), make sure to set `color.NoColor = false` so that it bypasses the check for non-tty output streams.
+
+## Todo
+
+* Save/Return previous values
+* Evaluate fmt.Formatter interface
+
+
+## Credits
+
+ * [Fatih Arslan](https://github.com/fatih)
+ * Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable)
+
+## License
+
+The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details
diff --git a/vendor/github.com/fatih/color/color.go b/vendor/github.com/fatih/color/color.go
new file mode 100644
index 0000000..98a60f3
--- /dev/null
+++ b/vendor/github.com/fatih/color/color.go
@@ -0,0 +1,618 @@
+package color
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "strconv"
+ "strings"
+ "sync"
+
+ "github.com/mattn/go-colorable"
+ "github.com/mattn/go-isatty"
+)
+
+var (
+ // NoColor defines if the output is colorized or not. It's dynamically set to
+ // false or true based on the stdout's file descriptor referring to a terminal
+ // or not. It's also set to true if the NO_COLOR environment variable is
+ // set (regardless of its value). This is a global option and affects all
+ // colors. For more control over each color block use the methods
+ // DisableColor() individually.
+ NoColor = noColorExists() || os.Getenv("TERM") == "dumb" ||
+ (!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
+
+ // Output defines the standard output of the print functions. By default
+ // os.Stdout is used.
+ Output = colorable.NewColorableStdout()
+
+ // Error defines a color supporting writer for os.Stderr.
+ Error = colorable.NewColorableStderr()
+
+ // colorsCache is used to reduce the count of created Color objects and
+ // allows to reuse already created objects with required Attribute.
+ colorsCache = make(map[Attribute]*Color)
+ colorsCacheMu sync.Mutex // protects colorsCache
+)
+
+// noColorExists returns true if the environment variable NO_COLOR exists.
+func noColorExists() bool {
+ _, exists := os.LookupEnv("NO_COLOR")
+ return exists
+}
+
+// Color defines a custom color object which is defined by SGR parameters.
+type Color struct {
+ params []Attribute
+ noColor *bool
+}
+
+// Attribute defines a single SGR Code
+type Attribute int
+
+const escape = "\x1b"
+
+// Base attributes
+const (
+ Reset Attribute = iota
+ Bold
+ Faint
+ Italic
+ Underline
+ BlinkSlow
+ BlinkRapid
+ ReverseVideo
+ Concealed
+ CrossedOut
+)
+
+// Foreground text colors
+const (
+ FgBlack Attribute = iota + 30
+ FgRed
+ FgGreen
+ FgYellow
+ FgBlue
+ FgMagenta
+ FgCyan
+ FgWhite
+)
+
+// Foreground Hi-Intensity text colors
+const (
+ FgHiBlack Attribute = iota + 90
+ FgHiRed
+ FgHiGreen
+ FgHiYellow
+ FgHiBlue
+ FgHiMagenta
+ FgHiCyan
+ FgHiWhite
+)
+
+// Background text colors
+const (
+ BgBlack Attribute = iota + 40
+ BgRed
+ BgGreen
+ BgYellow
+ BgBlue
+ BgMagenta
+ BgCyan
+ BgWhite
+)
+
+// Background Hi-Intensity text colors
+const (
+ BgHiBlack Attribute = iota + 100
+ BgHiRed
+ BgHiGreen
+ BgHiYellow
+ BgHiBlue
+ BgHiMagenta
+ BgHiCyan
+ BgHiWhite
+)
+
+// New returns a newly created color object.
+func New(value ...Attribute) *Color {
+ c := &Color{
+ params: make([]Attribute, 0),
+ }
+
+ if noColorExists() {
+ c.noColor = boolPtr(true)
+ }
+
+ c.Add(value...)
+ return c
+}
+
+// Set sets the given parameters immediately. It will change the color of
+// output with the given SGR parameters until color.Unset() is called.
+func Set(p ...Attribute) *Color {
+ c := New(p...)
+ c.Set()
+ return c
+}
+
+// Unset resets all escape attributes and clears the output. Usually should
+// be called after Set().
+func Unset() {
+ if NoColor {
+ return
+ }
+
+ fmt.Fprintf(Output, "%s[%dm", escape, Reset)
+}
+
+// Set sets the SGR sequence.
+func (c *Color) Set() *Color {
+ if c.isNoColorSet() {
+ return c
+ }
+
+ fmt.Fprintf(Output, c.format())
+ return c
+}
+
+func (c *Color) unset() {
+ if c.isNoColorSet() {
+ return
+ }
+
+ Unset()
+}
+
+func (c *Color) setWriter(w io.Writer) *Color {
+ if c.isNoColorSet() {
+ return c
+ }
+
+ fmt.Fprintf(w, c.format())
+ return c
+}
+
+func (c *Color) unsetWriter(w io.Writer) {
+ if c.isNoColorSet() {
+ return
+ }
+
+ if NoColor {
+ return
+ }
+
+ fmt.Fprintf(w, "%s[%dm", escape, Reset)
+}
+
+// Add is used to chain SGR parameters. Use as many as parameters to combine
+// and create custom color objects. Example: Add(color.FgRed, color.Underline).
+func (c *Color) Add(value ...Attribute) *Color {
+ c.params = append(c.params, value...)
+ return c
+}
+
+func (c *Color) prepend(value Attribute) {
+ c.params = append(c.params, 0)
+ copy(c.params[1:], c.params[0:])
+ c.params[0] = value
+}
+
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+// On Windows, users should wrap w with colorable.NewColorable() if w is of
+// type *os.File.
+func (c *Color) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+ c.setWriter(w)
+ defer c.unsetWriter(w)
+
+ return fmt.Fprint(w, a...)
+}
+
+// Print formats using the default formats for its operands and writes to
+// standard output. Spaces are added between operands when neither is a
+// string. It returns the number of bytes written and any write error
+// encountered. This is the standard fmt.Print() method wrapped with the given
+// color.
+func (c *Color) Print(a ...interface{}) (n int, err error) {
+ c.Set()
+ defer c.unset()
+
+ return fmt.Fprint(Output, a...)
+}
+
+// Fprintf formats according to a format specifier and writes to w.
+// It returns the number of bytes written and any write error encountered.
+// On Windows, users should wrap w with colorable.NewColorable() if w is of
+// type *os.File.
+func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
+ c.setWriter(w)
+ defer c.unsetWriter(w)
+
+ return fmt.Fprintf(w, format, a...)
+}
+
+// Printf formats according to a format specifier and writes to standard output.
+// It returns the number of bytes written and any write error encountered.
+// This is the standard fmt.Printf() method wrapped with the given color.
+func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
+ c.Set()
+ defer c.unset()
+
+ return fmt.Fprintf(Output, format, a...)
+}
+
+// Fprintln formats using the default formats for its operands and writes to w.
+// Spaces are always added between operands and a newline is appended.
+// On Windows, users should wrap w with colorable.NewColorable() if w is of
+// type *os.File.
+func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
+ c.setWriter(w)
+ defer c.unsetWriter(w)
+
+ return fmt.Fprintln(w, a...)
+}
+
+// Println formats using the default formats for its operands and writes to
+// standard output. Spaces are always added between operands and a newline is
+// appended. It returns the number of bytes written and any write error
+// encountered. This is the standard fmt.Print() method wrapped with the given
+// color.
+func (c *Color) Println(a ...interface{}) (n int, err error) {
+ c.Set()
+ defer c.unset()
+
+ return fmt.Fprintln(Output, a...)
+}
+
+// Sprint is just like Print, but returns a string instead of printing it.
+func (c *Color) Sprint(a ...interface{}) string {
+ return c.wrap(fmt.Sprint(a...))
+}
+
+// Sprintln is just like Println, but returns a string instead of printing it.
+func (c *Color) Sprintln(a ...interface{}) string {
+ return c.wrap(fmt.Sprintln(a...))
+}
+
+// Sprintf is just like Printf, but returns a string instead of printing it.
+func (c *Color) Sprintf(format string, a ...interface{}) string {
+ return c.wrap(fmt.Sprintf(format, a...))
+}
+
+// FprintFunc returns a new function that prints the passed arguments as
+// colorized with color.Fprint().
+func (c *Color) FprintFunc() func(w io.Writer, a ...interface{}) {
+ return func(w io.Writer, a ...interface{}) {
+ c.Fprint(w, a...)
+ }
+}
+
+// PrintFunc returns a new function that prints the passed arguments as
+// colorized with color.Print().
+func (c *Color) PrintFunc() func(a ...interface{}) {
+ return func(a ...interface{}) {
+ c.Print(a...)
+ }
+}
+
+// FprintfFunc returns a new function that prints the passed arguments as
+// colorized with color.Fprintf().
+func (c *Color) FprintfFunc() func(w io.Writer, format string, a ...interface{}) {
+ return func(w io.Writer, format string, a ...interface{}) {
+ c.Fprintf(w, format, a...)
+ }
+}
+
+// PrintfFunc returns a new function that prints the passed arguments as
+// colorized with color.Printf().
+func (c *Color) PrintfFunc() func(format string, a ...interface{}) {
+ return func(format string, a ...interface{}) {
+ c.Printf(format, a...)
+ }
+}
+
+// FprintlnFunc returns a new function that prints the passed arguments as
+// colorized with color.Fprintln().
+func (c *Color) FprintlnFunc() func(w io.Writer, a ...interface{}) {
+ return func(w io.Writer, a ...interface{}) {
+ c.Fprintln(w, a...)
+ }
+}
+
+// PrintlnFunc returns a new function that prints the passed arguments as
+// colorized with color.Println().
+func (c *Color) PrintlnFunc() func(a ...interface{}) {
+ return func(a ...interface{}) {
+ c.Println(a...)
+ }
+}
+
+// SprintFunc returns a new function that returns colorized strings for the
+// given arguments with fmt.Sprint(). Useful to put into or mix into other
+// string. Windows users should use this in conjunction with color.Output, example:
+//
+// put := New(FgYellow).SprintFunc()
+// fmt.Fprintf(color.Output, "This is a %s", put("warning"))
+func (c *Color) SprintFunc() func(a ...interface{}) string {
+ return func(a ...interface{}) string {
+ return c.wrap(fmt.Sprint(a...))
+ }
+}
+
+// SprintfFunc returns a new function that returns colorized strings for the
+// given arguments with fmt.Sprintf(). Useful to put into or mix into other
+// string. Windows users should use this in conjunction with color.Output.
+func (c *Color) SprintfFunc() func(format string, a ...interface{}) string {
+ return func(format string, a ...interface{}) string {
+ return c.wrap(fmt.Sprintf(format, a...))
+ }
+}
+
+// SprintlnFunc returns a new function that returns colorized strings for the
+// given arguments with fmt.Sprintln(). Useful to put into or mix into other
+// string. Windows users should use this in conjunction with color.Output.
+func (c *Color) SprintlnFunc() func(a ...interface{}) string {
+ return func(a ...interface{}) string {
+ return c.wrap(fmt.Sprintln(a...))
+ }
+}
+
+// sequence returns a formatted SGR sequence to be plugged into a "\x1b[...m"
+// an example output might be: "1;36" -> bold cyan
+func (c *Color) sequence() string {
+ format := make([]string, len(c.params))
+ for i, v := range c.params {
+ format[i] = strconv.Itoa(int(v))
+ }
+
+ return strings.Join(format, ";")
+}
+
+// wrap wraps the s string with the colors attributes. The string is ready to
+// be printed.
+func (c *Color) wrap(s string) string {
+ if c.isNoColorSet() {
+ return s
+ }
+
+ return c.format() + s + c.unformat()
+}
+
+func (c *Color) format() string {
+ return fmt.Sprintf("%s[%sm", escape, c.sequence())
+}
+
+func (c *Color) unformat() string {
+ return fmt.Sprintf("%s[%dm", escape, Reset)
+}
+
+// DisableColor disables the color output. Useful to not change any existing
+// code and still being able to output. Can be used for flags like
+// "--no-color". To enable back use EnableColor() method.
+func (c *Color) DisableColor() {
+ c.noColor = boolPtr(true)
+}
+
+// EnableColor enables the color output. Use it in conjunction with
+// DisableColor(). Otherwise this method has no side effects.
+func (c *Color) EnableColor() {
+ c.noColor = boolPtr(false)
+}
+
+func (c *Color) isNoColorSet() bool {
+ // check first if we have user set action
+ if c.noColor != nil {
+ return *c.noColor
+ }
+
+ // if not return the global option, which is disabled by default
+ return NoColor
+}
+
+// Equals returns a boolean value indicating whether two colors are equal.
+func (c *Color) Equals(c2 *Color) bool {
+ if len(c.params) != len(c2.params) {
+ return false
+ }
+
+ for _, attr := range c.params {
+ if !c2.attrExists(attr) {
+ return false
+ }
+ }
+
+ return true
+}
+
+func (c *Color) attrExists(a Attribute) bool {
+ for _, attr := range c.params {
+ if attr == a {
+ return true
+ }
+ }
+
+ return false
+}
+
+func boolPtr(v bool) *bool {
+ return &v
+}
+
+func getCachedColor(p Attribute) *Color {
+ colorsCacheMu.Lock()
+ defer colorsCacheMu.Unlock()
+
+ c, ok := colorsCache[p]
+ if !ok {
+ c = New(p)
+ colorsCache[p] = c
+ }
+
+ return c
+}
+
+func colorPrint(format string, p Attribute, a ...interface{}) {
+ c := getCachedColor(p)
+
+ if !strings.HasSuffix(format, "\n") {
+ format += "\n"
+ }
+
+ if len(a) == 0 {
+ c.Print(format)
+ } else {
+ c.Printf(format, a...)
+ }
+}
+
+func colorString(format string, p Attribute, a ...interface{}) string {
+ c := getCachedColor(p)
+
+ if len(a) == 0 {
+ return c.SprintFunc()(format)
+ }
+
+ return c.SprintfFunc()(format, a...)
+}
+
+// Black is a convenient helper function to print with black foreground. A
+// newline is appended to format by default.
+func Black(format string, a ...interface{}) { colorPrint(format, FgBlack, a...) }
+
+// Red is a convenient helper function to print with red foreground. A
+// newline is appended to format by default.
+func Red(format string, a ...interface{}) { colorPrint(format, FgRed, a...) }
+
+// Green is a convenient helper function to print with green foreground. A
+// newline is appended to format by default.
+func Green(format string, a ...interface{}) { colorPrint(format, FgGreen, a...) }
+
+// Yellow is a convenient helper function to print with yellow foreground.
+// A newline is appended to format by default.
+func Yellow(format string, a ...interface{}) { colorPrint(format, FgYellow, a...) }
+
+// Blue is a convenient helper function to print with blue foreground. A
+// newline is appended to format by default.
+func Blue(format string, a ...interface{}) { colorPrint(format, FgBlue, a...) }
+
+// Magenta is a convenient helper function to print with magenta foreground.
+// A newline is appended to format by default.
+func Magenta(format string, a ...interface{}) { colorPrint(format, FgMagenta, a...) }
+
+// Cyan is a convenient helper function to print with cyan foreground. A
+// newline is appended to format by default.
+func Cyan(format string, a ...interface{}) { colorPrint(format, FgCyan, a...) }
+
+// White is a convenient helper function to print with white foreground. A
+// newline is appended to format by default.
+func White(format string, a ...interface{}) { colorPrint(format, FgWhite, a...) }
+
+// BlackString is a convenient helper function to return a string with black
+// foreground.
+func BlackString(format string, a ...interface{}) string { return colorString(format, FgBlack, a...) }
+
+// RedString is a convenient helper function to return a string with red
+// foreground.
+func RedString(format string, a ...interface{}) string { return colorString(format, FgRed, a...) }
+
+// GreenString is a convenient helper function to return a string with green
+// foreground.
+func GreenString(format string, a ...interface{}) string { return colorString(format, FgGreen, a...) }
+
+// YellowString is a convenient helper function to return a string with yellow
+// foreground.
+func YellowString(format string, a ...interface{}) string { return colorString(format, FgYellow, a...) }
+
+// BlueString is a convenient helper function to return a string with blue
+// foreground.
+func BlueString(format string, a ...interface{}) string { return colorString(format, FgBlue, a...) }
+
+// MagentaString is a convenient helper function to return a string with magenta
+// foreground.
+func MagentaString(format string, a ...interface{}) string {
+ return colorString(format, FgMagenta, a...)
+}
+
+// CyanString is a convenient helper function to return a string with cyan
+// foreground.
+func CyanString(format string, a ...interface{}) string { return colorString(format, FgCyan, a...) }
+
+// WhiteString is a convenient helper function to return a string with white
+// foreground.
+func WhiteString(format string, a ...interface{}) string { return colorString(format, FgWhite, a...) }
+
+// HiBlack is a convenient helper function to print with hi-intensity black foreground. A
+// newline is appended to format by default.
+func HiBlack(format string, a ...interface{}) { colorPrint(format, FgHiBlack, a...) }
+
+// HiRed is a convenient helper function to print with hi-intensity red foreground. A
+// newline is appended to format by default.
+func HiRed(format string, a ...interface{}) { colorPrint(format, FgHiRed, a...) }
+
+// HiGreen is a convenient helper function to print with hi-intensity green foreground. A
+// newline is appended to format by default.
+func HiGreen(format string, a ...interface{}) { colorPrint(format, FgHiGreen, a...) }
+
+// HiYellow is a convenient helper function to print with hi-intensity yellow foreground.
+// A newline is appended to format by default.
+func HiYellow(format string, a ...interface{}) { colorPrint(format, FgHiYellow, a...) }
+
+// HiBlue is a convenient helper function to print with hi-intensity blue foreground. A
+// newline is appended to format by default.
+func HiBlue(format string, a ...interface{}) { colorPrint(format, FgHiBlue, a...) }
+
+// HiMagenta is a convenient helper function to print with hi-intensity magenta foreground.
+// A newline is appended to format by default.
+func HiMagenta(format string, a ...interface{}) { colorPrint(format, FgHiMagenta, a...) }
+
+// HiCyan is a convenient helper function to print with hi-intensity cyan foreground. A
+// newline is appended to format by default.
+func HiCyan(format string, a ...interface{}) { colorPrint(format, FgHiCyan, a...) }
+
+// HiWhite is a convenient helper function to print with hi-intensity white foreground. A
+// newline is appended to format by default.
+func HiWhite(format string, a ...interface{}) { colorPrint(format, FgHiWhite, a...) }
+
+// HiBlackString is a convenient helper function to return a string with hi-intensity black
+// foreground.
+func HiBlackString(format string, a ...interface{}) string {
+ return colorString(format, FgHiBlack, a...)
+}
+
+// HiRedString is a convenient helper function to return a string with hi-intensity red
+// foreground.
+func HiRedString(format string, a ...interface{}) string { return colorString(format, FgHiRed, a...) }
+
+// HiGreenString is a convenient helper function to return a string with hi-intensity green
+// foreground.
+func HiGreenString(format string, a ...interface{}) string {
+ return colorString(format, FgHiGreen, a...)
+}
+
+// HiYellowString is a convenient helper function to return a string with hi-intensity yellow
+// foreground.
+func HiYellowString(format string, a ...interface{}) string {
+ return colorString(format, FgHiYellow, a...)
+}
+
+// HiBlueString is a convenient helper function to return a string with hi-intensity blue
+// foreground.
+func HiBlueString(format string, a ...interface{}) string { return colorString(format, FgHiBlue, a...) }
+
+// HiMagentaString is a convenient helper function to return a string with hi-intensity magenta
+// foreground.
+func HiMagentaString(format string, a ...interface{}) string {
+ return colorString(format, FgHiMagenta, a...)
+}
+
+// HiCyanString is a convenient helper function to return a string with hi-intensity cyan
+// foreground.
+func HiCyanString(format string, a ...interface{}) string { return colorString(format, FgHiCyan, a...) }
+
+// HiWhiteString is a convenient helper function to return a string with hi-intensity white
+// foreground.
+func HiWhiteString(format string, a ...interface{}) string {
+ return colorString(format, FgHiWhite, a...)
+}
diff --git a/vendor/github.com/fatih/color/doc.go b/vendor/github.com/fatih/color/doc.go
new file mode 100644
index 0000000..04541de
--- /dev/null
+++ b/vendor/github.com/fatih/color/doc.go
@@ -0,0 +1,135 @@
+/*
+Package color is an ANSI color package to output colorized or SGR defined
+output to the standard output. The API can be used in several way, pick one
+that suits you.
+
+Use simple and default helper functions with predefined foreground colors:
+
+ color.Cyan("Prints text in cyan.")
+
+ // a newline will be appended automatically
+ color.Blue("Prints %s in blue.", "text")
+
+ // More default foreground colors..
+ color.Red("We have red")
+ color.Yellow("Yellow color too!")
+ color.Magenta("And many others ..")
+
+ // Hi-intensity colors
+ color.HiGreen("Bright green color.")
+ color.HiBlack("Bright black means gray..")
+ color.HiWhite("Shiny white color!")
+
+However there are times where custom color mixes are required. Below are some
+examples to create custom color objects and use the print functions of each
+separate color object.
+
+ // Create a new color object
+ c := color.New(color.FgCyan).Add(color.Underline)
+ c.Println("Prints cyan text with an underline.")
+
+ // Or just add them to New()
+ d := color.New(color.FgCyan, color.Bold)
+ d.Printf("This prints bold cyan %s\n", "too!.")
+
+
+ // Mix up foreground and background colors, create new mixes!
+ red := color.New(color.FgRed)
+
+ boldRed := red.Add(color.Bold)
+ boldRed.Println("This will print text in bold red.")
+
+ whiteBackground := red.Add(color.BgWhite)
+ whiteBackground.Println("Red text with White background.")
+
+ // Use your own io.Writer output
+ color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
+
+ blue := color.New(color.FgBlue)
+ blue.Fprint(myWriter, "This will print text in blue.")
+
+You can create PrintXxx functions to simplify even more:
+
+ // Create a custom print function for convenient
+ red := color.New(color.FgRed).PrintfFunc()
+ red("warning")
+ red("error: %s", err)
+
+ // Mix up multiple attributes
+ notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
+ notice("don't forget this...")
+
+You can also FprintXxx functions to pass your own io.Writer:
+
+ blue := color.New(FgBlue).FprintfFunc()
+ blue(myWriter, "important notice: %s", stars)
+
+ // Mix up with multiple attributes
+ success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
+ success(myWriter, don't forget this...")
+
+
+Or create SprintXxx functions to mix strings with other non-colorized strings:
+
+ yellow := New(FgYellow).SprintFunc()
+ red := New(FgRed).SprintFunc()
+
+ fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
+
+ info := New(FgWhite, BgGreen).SprintFunc()
+ fmt.Printf("this %s rocks!\n", info("package"))
+
+Windows support is enabled by default. All Print functions work as intended.
+However only for color.SprintXXX functions, user should use fmt.FprintXXX and
+set the output to color.Output:
+
+ fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
+
+ info := New(FgWhite, BgGreen).SprintFunc()
+ fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
+
+Using with existing code is possible. Just use the Set() method to set the
+standard output to the given parameters. That way a rewrite of an existing
+code is not required.
+
+ // Use handy standard colors.
+ color.Set(color.FgYellow)
+
+ fmt.Println("Existing text will be now in Yellow")
+ fmt.Printf("This one %s\n", "too")
+
+ color.Unset() // don't forget to unset
+
+ // You can mix up parameters
+ color.Set(color.FgMagenta, color.Bold)
+ defer color.Unset() // use it in your function
+
+ fmt.Println("All text will be now bold magenta.")
+
+There might be a case where you want to disable color output (for example to
+pipe the standard output of your app to somewhere else). `Color` has support to
+disable colors both globally and for single color definition. For example
+suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
+the color output with:
+
+ var flagNoColor = flag.Bool("no-color", false, "Disable color output")
+
+ if *flagNoColor {
+ color.NoColor = true // disables colorized output
+ }
+
+You can also disable the color by setting the NO_COLOR environment variable to any value.
+
+It also has support for single color definitions (local). You can
+disable/enable color output on the fly:
+
+ c := color.New(color.FgCyan)
+ c.Println("Prints cyan text")
+
+ c.DisableColor()
+ c.Println("This is printed without any color")
+
+ c.EnableColor()
+ c.Println("This prints again cyan...")
+*/
+package color
diff --git a/vendor/github.com/fatih/color/go.mod b/vendor/github.com/fatih/color/go.mod
new file mode 100644
index 0000000..c9b3cd5
--- /dev/null
+++ b/vendor/github.com/fatih/color/go.mod
@@ -0,0 +1,8 @@
+module github.com/fatih/color
+
+go 1.13
+
+require (
+ github.com/mattn/go-colorable v0.1.9
+ github.com/mattn/go-isatty v0.0.14
+)
diff --git a/vendor/github.com/fatih/color/go.sum b/vendor/github.com/fatih/color/go.sum
new file mode 100644
index 0000000..cbbcfb6
--- /dev/null
+++ b/vendor/github.com/fatih/color/go.sum
@@ -0,0 +1,9 @@
+github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
+github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
+github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/vendor/github.com/goccy/go-yaml/.codecov.yml b/vendor/github.com/goccy/go-yaml/.codecov.yml
new file mode 100644
index 0000000..8364eea
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/.codecov.yml
@@ -0,0 +1,31 @@
+codecov:
+ require_ci_to_pass: yes
+
+coverage:
+ precision: 2
+ round: down
+ range: "70...100"
+
+ status:
+ project:
+ default:
+ target: 75%
+ threshold: 2%
+ patch: off
+ changes: no
+
+parsers:
+ gcov:
+ branch_detection:
+ conditional: yes
+ loop: yes
+ method: no
+ macro: no
+
+comment:
+ layout: "header,diff"
+ behavior: default
+ require_changes: no
+
+ignore:
+ - ast
diff --git a/vendor/github.com/goccy/go-yaml/CHANGELOG.md b/vendor/github.com/goccy/go-yaml/CHANGELOG.md
new file mode 100644
index 0000000..e9ecd39
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/CHANGELOG.md
@@ -0,0 +1,102 @@
+## v1.9.5 - 2022-01-12
+
+### New Features
+
+* Add UseSingleQuote option ( #265 )
+
+### Fix bugs
+
+* Preserve defaults while decoding nested structs ( #260 )
+* Fix minor typo in decodeInit error ( #264 )
+* Handle empty sequence entries ( #275 )
+* Fix encoding of sequence with multiline string ( #276 )
+* Fix encoding of BytesMarshaler type ( #277 )
+* Fix indentState logic for multi-line value ( #278 )
+
+## v1.9.4 - 2021-10-12
+
+### Fix bugs
+
+* Keep prev/next reference between tokens containing comments when filtering comment tokens ( #257 )
+* Supports escaping reserved keywords in PathBuilder ( #258 )
+
+## v1.9.3 - 2021-09-07
+
+### New Features
+
+* Support encoding and decoding `time.Duration` fields ( #246 )
+* Allow reserved characters for key name in YAMLPath ( #251 )
+* Support getting YAMLPath from ast.Node ( #252 )
+* Support CommentToMap option ( #253 )
+
+### Fix bugs
+
+* Fix encoding nested sequences with `yaml.IndentSequence` ( #241 )
+* Fix error reporting on inline structs in strict mode ( #244, #245 )
+* Fix encoding of large floats ( #247 )
+
+### Improve workflow
+
+* Migrate CI from CircleCI to GitHub Action ( #249 )
+* Add workflow for ycat ( #250 )
+
+## v1.9.2 - 2021-07-26
+
+### Support WithComment option ( #238 )
+
+`yaml.WithComment` is a option for encoding with comment.
+The position where you want to add a comment is represented by YAMLPath, and it is the key of `yaml.CommentMap`.
+Also, you can select `Head` comment or `Line` comment as the comment type.
+
+## v1.9.1 - 2021-07-20
+
+### Fix DecodeFromNode ( #237 )
+
+- Fix YAML handling where anchor exists
+
+## v1.9.0 - 2021-07-19
+
+### New features
+
+- Support encoding of comment node ( #233 )
+- Support `yaml.NodeToValue(ast.Node, interface{}, ...DecodeOption) error` ( #236 )
+ - Can convert a AST node to a value directly
+
+### Fix decoder for comment
+
+- Fix parsing of literal with comment ( #234 )
+
+### Rename API ( #235 )
+
+- Rename `MarshalWithContext` to `MarshalContext`
+- Rename `UnmarshalWithContext` to `UnmarshalContext`
+
+## v1.8.10 - 2021-07-02
+
+### Fixed bugs
+
+- Fix searching anchor by alias name ( #212 )
+- Fixing Issue 186, scanner should account for newline characters when processing multi-line text. Without this source annotations line/column number (for this and all subsequent tokens) is inconsistent with plain text editors. e.g. https://github.com/goccy/go-yaml/issues/186. This addresses the issue specifically for single and double quote text only. ( #210 )
+- Add error for unterminated flow mapping node ( #213 )
+- Handle missing required field validation ( #221 )
+- Nicely format unexpected node type errors ( #229 )
+- Support to encode map which has defined type key ( #231 )
+
+### New features
+
+- Support sequence indentation by EncodeOption ( #232 )
+
+## v1.8.9 - 2021-03-01
+
+### Fixed bugs
+
+- Fix origin buffer for DocumentHeader and DocumentEnd and Directive
+- Fix origin buffer for anchor value
+- Fix syntax error about map value
+- Fix parsing MergeKey ('<<') characters
+- Fix encoding of float value
+- Fix incorrect column annotation when single or double quotes are used
+
+### New features
+
+- Support to encode/decode of ast.Node directly
diff --git a/vendor/github.com/goccy/go-yaml/LICENSE b/vendor/github.com/goccy/go-yaml/LICENSE
new file mode 100644
index 0000000..04485ce
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Masaaki Goshima
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/goccy/go-yaml/Makefile b/vendor/github.com/goccy/go-yaml/Makefile
new file mode 100644
index 0000000..45281a6
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/Makefile
@@ -0,0 +1,15 @@
+.PHONY: test
+test:
+ go test -v -race ./...
+
+.PHONY: cover
+cover:
+ go test -coverprofile=cover.out ./...
+
+.PHONY: cover-html
+cover-html: cover
+ go tool cover -html=cover.out
+
+.PHONY: ycat/build
+ycat/build:
+ go build -o ycat ./cmd/ycat
diff --git a/vendor/github.com/goccy/go-yaml/README.md b/vendor/github.com/goccy/go-yaml/README.md
new file mode 100644
index 0000000..9452349
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/README.md
@@ -0,0 +1,370 @@
+# YAML support for the Go language
+
+[![PkgGoDev](https://pkg.go.dev/badge/github.com/goccy/go-yaml)](https://pkg.go.dev/github.com/goccy/go-yaml)
+![Go](https://github.com/goccy/go-yaml/workflows/Go/badge.svg)
+[![codecov](https://codecov.io/gh/goccy/go-yaml/branch/master/graph/badge.svg)](https://codecov.io/gh/goccy/go-yaml)
+[![Go Report Card](https://goreportcard.com/badge/github.com/goccy/go-yaml)](https://goreportcard.com/report/github.com/goccy/go-yaml)
+
+
+
+# Why a new library?
+
+As of this writing, there already exists a de facto standard library for YAML processing for Go: [https://github.com/go-yaml/yaml](https://github.com/go-yaml/yaml). However we feel that some features are lacking, namely:
+
+- Pretty format for error notifications
+- Direct manipulation of YAML abstract syntax tree
+- Support for `Anchor` and `Alias` when marshaling
+- Allow referencing elements declared in another file via anchors
+
+# Features
+
+- Pretty format for error notifications
+- Supports `Scanner` or `Lexer` or `Parser` as public API
+- Supports `Anchor` and `Alias` to Marshaler
+- Allow referencing elements declared in another file via anchors
+- Extract value or AST by YAMLPath ( YAMLPath is like a JSONPath )
+
+# Installation
+
+```sh
+go get -u github.com/goccy/go-yaml
+```
+
+# Synopsis
+
+## 1. Simple Encode/Decode
+
+Has an interface like `go-yaml/yaml` using `reflect`
+
+```go
+var v struct {
+ A int
+ B string
+}
+v.A = 1
+v.B = "hello"
+bytes, err := yaml.Marshal(v)
+if err != nil {
+ //...
+}
+fmt.Println(string(bytes)) // "a: 1\nb: hello\n"
+```
+
+```go
+ yml := `
+%YAML 1.2
+---
+a: 1
+b: c
+`
+var v struct {
+ A int
+ B string
+}
+if err := yaml.Unmarshal([]byte(yml), &v); err != nil {
+ //...
+}
+```
+
+To control marshal/unmarshal behavior, you can use the `yaml` tag.
+
+```go
+ yml := `---
+foo: 1
+bar: c
+`
+var v struct {
+ A int `yaml:"foo"`
+ B string `yaml:"bar"`
+}
+if err := yaml.Unmarshal([]byte(yml), &v); err != nil {
+ //...
+}
+```
+
+For convenience, we also accept the `json` tag. Note that not all options from
+the `json` tag will have significance when parsing YAML documents. If both
+tags exist, `yaml` tag will take precedence.
+
+```go
+ yml := `---
+foo: 1
+bar: c
+`
+var v struct {
+ A int `json:"foo"`
+ B string `json:"bar"`
+}
+if err := yaml.Unmarshal([]byte(yml), &v); err != nil {
+ //...
+}
+```
+
+For custom marshal/unmarshaling, implement either `Bytes` or `Interface` variant of marshaler/unmarshaler. The difference is that while `BytesMarshaler`/`BytesUnmarshaler` behaves like [`encoding/json`](https://pkg.go.dev/encoding/json) and `InterfaceMarshaler`/`InterfaceUnmarshaler` behaves like [`gopkg.in/yaml.v2`](https://pkg.go.dev/gopkg.in/yaml.v2).
+
+Semantically both are the same, but they differ in performance. Because indentation matters in YAML, you cannot simply accept a valid YAML fragment from a Marshaler, and expect it to work when it is attached to the parent container's serialized form. Therefore when we receive use the `BytesMarshaler`, which returns `[]byte`, we must decode it once to figure out how to make it work in the given context. If you use the `InterfaceMarshaler`, we can skip the decoding.
+
+If you are repeatedly marshaling complex objects, the latter is always better
+performance wise. But if you are, for example, just providing a choice between
+a config file format that is read only once, the former is probably easier to
+code.
+
+## 2. Reference elements declared in another file
+
+`testdata` directory contains `anchor.yml` file:
+
+```shell
+├── testdata
+ └── anchor.yml
+```
+
+And `anchor.yml` is defined as follows:
+
+```yaml
+a: &a
+ b: 1
+ c: hello
+```
+
+Then, if `yaml.ReferenceDirs("testdata")` option is passed to `yaml.Decoder`,
+ `Decoder` tries to find the anchor definition from YAML files the under `testdata` directory.
+
+```go
+buf := bytes.NewBufferString("a: *a\n")
+dec := yaml.NewDecoder(buf, yaml.ReferenceDirs("testdata"))
+var v struct {
+ A struct {
+ B int
+ C string
+ }
+}
+if err := dec.Decode(&v); err != nil {
+ //...
+}
+fmt.Printf("%+v\n", v) // {A:{B:1 C:hello}}
+```
+
+## 3. Encode with `Anchor` and `Alias`
+
+### 3.1. Explicitly declared `Anchor` name and `Alias` name
+
+If you want to use `anchor` or `alias`, you can define it as a struct tag.
+
+```go
+type T struct {
+ A int
+ B string
+}
+var v struct {
+ C *T `yaml:"c,anchor=x"`
+ D *T `yaml:"d,alias=x"`
+}
+v.C = &T{A: 1, B: "hello"}
+v.D = v.C
+bytes, err := yaml.Marshal(v)
+if err != nil {
+ panic(err)
+}
+fmt.Println(string(bytes))
+/*
+c: &x
+ a: 1
+ b: hello
+d: *x
+*/
+```
+
+### 3.2. Implicitly declared `Anchor` and `Alias` names
+
+If you do not explicitly declare the anchor name, the default behavior is to
+use the equivalent of `strings.ToLower($FieldName)` as the name of the anchor.
+
+If you do not explicitly declare the alias name AND the value is a pointer
+to another element, we look up the anchor name by finding out which anchor
+field the value is assigned to by looking up its pointer address.
+
+```go
+type T struct {
+ I int
+ S string
+}
+var v struct {
+ A *T `yaml:"a,anchor"`
+ B *T `yaml:"b,anchor"`
+ C *T `yaml:"c,alias"`
+ D *T `yaml:"d,alias"`
+}
+v.A = &T{I: 1, S: "hello"}
+v.B = &T{I: 2, S: "world"}
+v.C = v.A // C has same pointer address to A
+v.D = v.B // D has same pointer address to B
+bytes, err := yaml.Marshal(v)
+if err != nil {
+ //...
+}
+fmt.Println(string(bytes))
+/*
+a: &a
+ i: 1
+ s: hello
+b: &b
+ i: 2
+ s: world
+c: *a
+d: *b
+*/
+```
+
+### 3.3 MergeKey and Alias
+
+Merge key and alias ( `<<: *alias` ) can be used by embedding a structure with the `inline,alias` tag.
+
+```go
+type Person struct {
+ *Person `yaml:",omitempty,inline,alias"` // embed Person type for default value
+ Name string `yaml:",omitempty"`
+ Age int `yaml:",omitempty"`
+}
+defaultPerson := &Person{
+ Name: "John Smith",
+ Age: 20,
+}
+people := []*Person{
+ {
+ Person: defaultPerson, // assign default value
+ Name: "Ken", // override Name property
+ Age: 10, // override Age property
+ },
+ {
+ Person: defaultPerson, // assign default value only
+ },
+}
+var doc struct {
+ Default *Person `yaml:"default,anchor"`
+ People []*Person `yaml:"people"`
+}
+doc.Default = defaultPerson
+doc.People = people
+bytes, err := yaml.Marshal(doc)
+if err != nil {
+ //...
+}
+fmt.Println(string(bytes))
+/*
+default: &default
+ name: John Smith
+ age: 20
+people:
+- <<: *default
+ name: Ken
+ age: 10
+- <<: *default
+*/
+```
+
+## 4. Pretty Formatted Errors
+
+Error values produced during parsing have two extra features over regular
+error values.
+
+First, by default, they contain extra information on the location of the error
+from the source YAML document, to make it easier to find the error location.
+
+Second, the error messages can optionally be colorized.
+
+If you would like to control exactly how the output looks like, consider
+using `yaml.FormatError`, which accepts two boolean values to
+control turning these features on or off.
+
+
+
+## 5. Use YAMLPath
+
+```go
+yml := `
+store:
+ book:
+ - author: john
+ price: 10
+ - author: ken
+ price: 12
+ bicycle:
+ color: red
+ price: 19.95
+`
+path, err := yaml.PathString("$.store.book[*].author")
+if err != nil {
+ //...
+}
+var authors []string
+if err := path.Read(strings.NewReader(yml), &authors); err != nil {
+ //...
+}
+fmt.Println(authors)
+// [john ken]
+```
+
+### 5.1 Print customized error with YAML source code
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/goccy/go-yaml"
+)
+
+func main() {
+ yml := `
+a: 1
+b: "hello"
+`
+ var v struct {
+ A int
+ B string
+ }
+ if err := yaml.Unmarshal([]byte(yml), &v); err != nil {
+ panic(err)
+ }
+ if v.A != 2 {
+ // output error with YAML source
+ path, err := yaml.PathString("$.a")
+ if err != nil {
+ panic(err)
+ }
+ source, err := path.AnnotateSource([]byte(yml), true)
+ if err != nil {
+ panic(err)
+ }
+ fmt.Printf("a value expected 2 but actual %d:\n%s\n", v.A, string(source))
+ }
+}
+```
+
+output result is the following:
+
+
+
+
+# Tools
+
+## ycat
+
+print yaml file with color
+
+
+
+### Installation
+
+```sh
+go install github.com/goccy/go-yaml/cmd/ycat@latest
+```
+
+# Looking for Sponsors
+
+I'm looking for sponsors this library. This library is being developed as a personal project in my spare time. If you want a quick response or problem resolution when using this library in your project, please register as a [sponsor](https://github.com/sponsors/goccy). I will cooperate as much as possible. Of course, this library is developed as an MIT license, so you can use it freely for free.
+
+# License
+
+MIT
diff --git a/vendor/github.com/goccy/go-yaml/ast/ast.go b/vendor/github.com/goccy/go-yaml/ast/ast.go
new file mode 100644
index 0000000..fa3e5e0
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/ast/ast.go
@@ -0,0 +1,2162 @@
+package ast
+
+import (
+ "fmt"
+ "io"
+ "math"
+ "strconv"
+ "strings"
+
+ "github.com/goccy/go-yaml/token"
+ "golang.org/x/xerrors"
+)
+
+var (
+ ErrInvalidTokenType = xerrors.New("invalid token type")
+ ErrInvalidAnchorName = xerrors.New("invalid anchor name")
+ ErrInvalidAliasName = xerrors.New("invalid alias name")
+)
+
+// NodeType type identifier of node
+type NodeType int
+
+const (
+ // UnknownNodeType type identifier for default
+ UnknownNodeType NodeType = iota
+ // DocumentType type identifier for document node
+ DocumentType
+ // NullType type identifier for null node
+ NullType
+ // BoolType type identifier for boolean node
+ BoolType
+ // IntegerType type identifier for integer node
+ IntegerType
+ // FloatType type identifier for float node
+ FloatType
+ // InfinityType type identifier for infinity node
+ InfinityType
+ // NanType type identifier for nan node
+ NanType
+ // StringType type identifier for string node
+ StringType
+ // MergeKeyType type identifier for merge key node
+ MergeKeyType
+ // LiteralType type identifier for literal node
+ LiteralType
+ // MappingType type identifier for mapping node
+ MappingType
+ // MappingKeyType type identifier for mapping key node
+ MappingKeyType
+ // MappingValueType type identifier for mapping value node
+ MappingValueType
+ // SequenceType type identifier for sequence node
+ SequenceType
+ // AnchorType type identifier for anchor node
+ AnchorType
+ // AliasType type identifier for alias node
+ AliasType
+ // DirectiveType type identifier for directive node
+ DirectiveType
+ // TagType type identifier for tag node
+ TagType
+ // CommentType type identifier for comment node
+ CommentType
+ // CommentGroupType type identifier for comment group node
+ CommentGroupType
+)
+
+// String node type identifier to text
+func (t NodeType) String() string {
+ switch t {
+ case UnknownNodeType:
+ return "UnknownNode"
+ case DocumentType:
+ return "Document"
+ case NullType:
+ return "Null"
+ case BoolType:
+ return "Bool"
+ case IntegerType:
+ return "Integer"
+ case FloatType:
+ return "Float"
+ case InfinityType:
+ return "Infinity"
+ case NanType:
+ return "Nan"
+ case StringType:
+ return "String"
+ case MergeKeyType:
+ return "MergeKey"
+ case LiteralType:
+ return "Literal"
+ case MappingType:
+ return "Mapping"
+ case MappingKeyType:
+ return "MappingKey"
+ case MappingValueType:
+ return "MappingValue"
+ case SequenceType:
+ return "Sequence"
+ case AnchorType:
+ return "Anchor"
+ case AliasType:
+ return "Alias"
+ case DirectiveType:
+ return "Directive"
+ case TagType:
+ return "Tag"
+ case CommentType:
+ return "Comment"
+ case CommentGroupType:
+ return "CommentGroup"
+ }
+ return ""
+}
+
+// String node type identifier to YAML Structure name
+// based on https://yaml.org/spec/1.2/spec.html
+func (t NodeType) YAMLName() string {
+ switch t {
+ case UnknownNodeType:
+ return "unknown"
+ case DocumentType:
+ return "document"
+ case NullType:
+ return "null"
+ case BoolType:
+ return "boolean"
+ case IntegerType:
+ return "int"
+ case FloatType:
+ return "float"
+ case InfinityType:
+ return "inf"
+ case NanType:
+ return "nan"
+ case StringType:
+ return "string"
+ case MergeKeyType:
+ return "merge key"
+ case LiteralType:
+ return "scalar"
+ case MappingType:
+ return "mapping"
+ case MappingKeyType:
+ return "key"
+ case MappingValueType:
+ return "value"
+ case SequenceType:
+ return "sequence"
+ case AnchorType:
+ return "anchor"
+ case AliasType:
+ return "alias"
+ case DirectiveType:
+ return "directive"
+ case TagType:
+ return "tag"
+ case CommentType:
+ return "comment"
+ case CommentGroupType:
+ return "comment"
+ }
+ return ""
+}
+
+// Node type of node
+type Node interface {
+ io.Reader
+ // String node to text
+ String() string
+ // GetToken returns token instance
+ GetToken() *token.Token
+ // Type returns type of node
+ Type() NodeType
+ // AddColumn add column number to child nodes recursively
+ AddColumn(int)
+ // SetComment set comment token to node
+ SetComment(*CommentGroupNode) error
+ // Comment returns comment token instance
+ GetComment() *CommentGroupNode
+ // GetPath returns YAMLPath for the current node
+ GetPath() string
+ // SetPath set YAMLPath for the current node
+ SetPath(string)
+ // MarshalYAML
+ MarshalYAML() ([]byte, error)
+ // already read length
+ readLen() int
+ // append read length
+ addReadLen(int)
+ // clean read length
+ clearLen()
+ // String node to text without comment
+ stringWithoutComment() string
+}
+
+// ScalarNode type for scalar node
+type ScalarNode interface {
+ Node
+ GetValue() interface{}
+}
+
+type BaseNode struct {
+ Path string
+ Comment *CommentGroupNode
+ read int
+}
+
+func addCommentString(base string, node *CommentGroupNode) string {
+ return fmt.Sprintf("%s %s", base, node.String())
+}
+
+func (n *BaseNode) readLen() int {
+ return n.read
+}
+
+func (n *BaseNode) clearLen() {
+ n.read = 0
+}
+
+func (n *BaseNode) addReadLen(len int) {
+ n.read += len
+}
+
+// GetPath returns YAMLPath for the current node.
+func (n *BaseNode) GetPath() string {
+ if n == nil {
+ return ""
+ }
+ return n.Path
+}
+
+// SetPath set YAMLPath for the current node.
+func (n *BaseNode) SetPath(path string) {
+ if n == nil {
+ return
+ }
+ n.Path = path
+}
+
+// GetComment returns comment token instance
+func (n *BaseNode) GetComment() *CommentGroupNode {
+ return n.Comment
+}
+
+// SetComment set comment token
+func (n *BaseNode) SetComment(node *CommentGroupNode) error {
+ n.Comment = node
+ return nil
+}
+
+func min(a, b int) int {
+ if a < b {
+ return a
+ }
+ return b
+}
+
+func readNode(p []byte, node Node) (int, error) {
+ s := node.String()
+ readLen := node.readLen()
+ remain := len(s) - readLen
+ if remain == 0 {
+ node.clearLen()
+ return 0, io.EOF
+ }
+ size := min(remain, len(p))
+ for idx, b := range s[readLen : readLen+size] {
+ p[idx] = byte(b)
+ }
+ node.addReadLen(size)
+ return size, nil
+}
+
+// Null create node for null value
+func Null(tk *token.Token) Node {
+ return &NullNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ }
+}
+
+// Bool create node for boolean value
+func Bool(tk *token.Token) Node {
+ b, _ := strconv.ParseBool(tk.Value)
+ return &BoolNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: b,
+ }
+}
+
+// Integer create node for integer value
+func Integer(tk *token.Token) Node {
+ value := removeUnderScoreFromNumber(tk.Value)
+ switch tk.Type {
+ case token.BinaryIntegerType:
+ // skip two characters because binary token starts with '0b'
+ skipCharacterNum := 2
+ negativePrefix := ""
+ if value[0] == '-' {
+ skipCharacterNum++
+ negativePrefix = "-"
+ }
+ if len(negativePrefix) > 0 {
+ i, _ := strconv.ParseInt(negativePrefix+value[skipCharacterNum:], 2, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+ }
+ i, _ := strconv.ParseUint(negativePrefix+value[skipCharacterNum:], 2, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+ case token.OctetIntegerType:
+ // octet token starts with '0o' or '-0o' or '0' or '-0'
+ skipCharacterNum := 1
+ negativePrefix := ""
+ if value[0] == '-' {
+ skipCharacterNum++
+ if len(value) > 2 && value[2] == 'o' {
+ skipCharacterNum++
+ }
+ negativePrefix = "-"
+ } else {
+ if value[1] == 'o' {
+ skipCharacterNum++
+ }
+ }
+ if len(negativePrefix) > 0 {
+ i, _ := strconv.ParseInt(negativePrefix+value[skipCharacterNum:], 8, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+ }
+ i, _ := strconv.ParseUint(value[skipCharacterNum:], 8, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+ case token.HexIntegerType:
+ // hex token starts with '0x' or '-0x'
+ skipCharacterNum := 2
+ negativePrefix := ""
+ if value[0] == '-' {
+ skipCharacterNum++
+ negativePrefix = "-"
+ }
+ if len(negativePrefix) > 0 {
+ i, _ := strconv.ParseInt(negativePrefix+value[skipCharacterNum:], 16, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+ }
+ i, _ := strconv.ParseUint(value[skipCharacterNum:], 16, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+ }
+ if value[0] == '-' || value[0] == '+' {
+ i, _ := strconv.ParseInt(value, 10, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+ }
+ i, _ := strconv.ParseUint(value, 10, 64)
+ return &IntegerNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: i,
+ }
+}
+
+// Float create node for float value
+func Float(tk *token.Token) Node {
+ f, _ := strconv.ParseFloat(removeUnderScoreFromNumber(tk.Value), 64)
+ return &FloatNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: f,
+ }
+}
+
+// Infinity create node for .inf or -.inf value
+func Infinity(tk *token.Token) *InfinityNode {
+ node := &InfinityNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ }
+ switch tk.Value {
+ case ".inf", ".Inf", ".INF":
+ node.Value = math.Inf(0)
+ case "-.inf", "-.Inf", "-.INF":
+ node.Value = math.Inf(-1)
+ }
+ return node
+}
+
+// Nan create node for .nan value
+func Nan(tk *token.Token) *NanNode {
+ return &NanNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ }
+}
+
+// String create node for string value
+func String(tk *token.Token) *StringNode {
+ return &StringNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ Value: tk.Value,
+ }
+}
+
+// Comment create node for comment
+func Comment(tk *token.Token) *CommentNode {
+ return &CommentNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ }
+}
+
+func CommentGroup(comments []*token.Token) *CommentGroupNode {
+ nodes := []*CommentNode{}
+ for _, comment := range comments {
+ nodes = append(nodes, Comment(comment))
+ }
+ return &CommentGroupNode{
+ BaseNode: &BaseNode{},
+ Comments: nodes,
+ }
+}
+
+// MergeKey create node for merge key ( << )
+func MergeKey(tk *token.Token) *MergeKeyNode {
+ return &MergeKeyNode{
+ BaseNode: &BaseNode{},
+ Token: tk,
+ }
+}
+
+// Mapping create node for map
+func Mapping(tk *token.Token, isFlowStyle bool, values ...*MappingValueNode) *MappingNode {
+ node := &MappingNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ IsFlowStyle: isFlowStyle,
+ Values: []*MappingValueNode{},
+ }
+ node.Values = append(node.Values, values...)
+ return node
+}
+
+// MappingValue create node for mapping value
+func MappingValue(tk *token.Token, key Node, value Node) *MappingValueNode {
+ return &MappingValueNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ Key: key,
+ Value: value,
+ }
+}
+
+// MappingKey create node for map key ( '?' ).
+func MappingKey(tk *token.Token) *MappingKeyNode {
+ return &MappingKeyNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ }
+}
+
+// Sequence create node for sequence
+func Sequence(tk *token.Token, isFlowStyle bool) *SequenceNode {
+ return &SequenceNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ IsFlowStyle: isFlowStyle,
+ Values: []Node{},
+ }
+}
+
+func Anchor(tk *token.Token) *AnchorNode {
+ return &AnchorNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ }
+}
+
+func Alias(tk *token.Token) *AliasNode {
+ return &AliasNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ }
+}
+
+func Document(tk *token.Token, body Node) *DocumentNode {
+ return &DocumentNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ Body: body,
+ }
+}
+
+func Directive(tk *token.Token) *DirectiveNode {
+ return &DirectiveNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ }
+}
+
+func Literal(tk *token.Token) *LiteralNode {
+ return &LiteralNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ }
+}
+
+func Tag(tk *token.Token) *TagNode {
+ return &TagNode{
+ BaseNode: &BaseNode{},
+ Start: tk,
+ }
+}
+
+// File contains all documents in YAML file
+type File struct {
+ Name string
+ Docs []*DocumentNode
+}
+
+// Read implements (io.Reader).Read
+func (f *File) Read(p []byte) (int, error) {
+ for _, doc := range f.Docs {
+ n, err := doc.Read(p)
+ if err == io.EOF {
+ continue
+ }
+ return n, nil
+ }
+ return 0, io.EOF
+}
+
+// String all documents to text
+func (f *File) String() string {
+ docs := []string{}
+ for _, doc := range f.Docs {
+ docs = append(docs, doc.String())
+ }
+ return strings.Join(docs, "\n")
+}
+
+func (f *File) stringWithoutComment() string {
+ return f.String()
+}
+
+// DocumentNode type of Document
+type DocumentNode struct {
+ *BaseNode
+ Start *token.Token // position of DocumentHeader ( `---` )
+ End *token.Token // position of DocumentEnd ( `...` )
+ Body Node
+}
+
+// Read implements (io.Reader).Read
+func (d *DocumentNode) Read(p []byte) (int, error) {
+ return readNode(p, d)
+}
+
+// Type returns DocumentNodeType
+func (d *DocumentNode) Type() NodeType { return DocumentType }
+
+// GetToken returns token instance
+func (d *DocumentNode) GetToken() *token.Token {
+ return d.Body.GetToken()
+}
+
+// AddColumn add column number to child nodes recursively
+func (d *DocumentNode) AddColumn(col int) {
+ if d.Body != nil {
+ d.Body.AddColumn(col)
+ }
+}
+
+// String document to text
+func (d *DocumentNode) String() string {
+ doc := []string{}
+ if d.Start != nil {
+ doc = append(doc, d.Start.Value)
+ }
+ doc = append(doc, d.Body.String())
+ if d.End != nil {
+ doc = append(doc, d.End.Value)
+ }
+ return strings.Join(doc, "\n")
+}
+
+func (d *DocumentNode) stringWithoutComment() string {
+ return d.String()
+}
+
+// MarshalYAML encodes to a YAML text
+func (d *DocumentNode) MarshalYAML() ([]byte, error) {
+ return []byte(d.String()), nil
+}
+
+func removeUnderScoreFromNumber(num string) string {
+ return strings.ReplaceAll(num, "_", "")
+}
+
+// NullNode type of null node
+type NullNode struct {
+ *BaseNode
+ Token *token.Token
+}
+
+// Read implements (io.Reader).Read
+func (n *NullNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns NullType
+func (n *NullNode) Type() NodeType { return NullType }
+
+// GetToken returns token instance
+func (n *NullNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *NullNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// GetValue returns nil value
+func (n *NullNode) GetValue() interface{} {
+ return nil
+}
+
+// String returns `null` text
+func (n *NullNode) String() string {
+ if n.Comment != nil {
+ return fmt.Sprintf("null %s", n.Comment.String())
+ }
+ return n.stringWithoutComment()
+}
+
+func (n *NullNode) stringWithoutComment() string {
+ return "null"
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *NullNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// IntegerNode type of integer node
+type IntegerNode struct {
+ *BaseNode
+ Token *token.Token
+ Value interface{} // int64 or uint64 value
+}
+
+// Read implements (io.Reader).Read
+func (n *IntegerNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns IntegerType
+func (n *IntegerNode) Type() NodeType { return IntegerType }
+
+// GetToken returns token instance
+func (n *IntegerNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *IntegerNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// GetValue returns int64 value
+func (n *IntegerNode) GetValue() interface{} {
+ return n.Value
+}
+
+// String int64 to text
+func (n *IntegerNode) String() string {
+ if n.Comment != nil {
+ return addCommentString(n.Token.Value, n.Comment)
+ }
+ return n.stringWithoutComment()
+}
+
+func (n *IntegerNode) stringWithoutComment() string {
+ return n.Token.Value
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *IntegerNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// FloatNode type of float node
+type FloatNode struct {
+ *BaseNode
+ Token *token.Token
+ Precision int
+ Value float64
+}
+
+// Read implements (io.Reader).Read
+func (n *FloatNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns FloatType
+func (n *FloatNode) Type() NodeType { return FloatType }
+
+// GetToken returns token instance
+func (n *FloatNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *FloatNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// GetValue returns float64 value
+func (n *FloatNode) GetValue() interface{} {
+ return n.Value
+}
+
+// String float64 to text
+func (n *FloatNode) String() string {
+ if n.Comment != nil {
+ return addCommentString(n.Token.Value, n.Comment)
+ }
+ return n.stringWithoutComment()
+}
+
+func (n *FloatNode) stringWithoutComment() string {
+ return n.Token.Value
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *FloatNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// StringNode type of string node
+type StringNode struct {
+ *BaseNode
+ Token *token.Token
+ Value string
+}
+
+// Read implements (io.Reader).Read
+func (n *StringNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns StringType
+func (n *StringNode) Type() NodeType { return StringType }
+
+// GetToken returns token instance
+func (n *StringNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *StringNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// GetValue returns string value
+func (n *StringNode) GetValue() interface{} {
+ return n.Value
+}
+
+// escapeSingleQuote escapes s to a single quoted scalar.
+// https://yaml.org/spec/1.2.2/#732-single-quoted-style
+func escapeSingleQuote(s string) string {
+ var sb strings.Builder
+ growLen := len(s) + // s includes also one ' from the doubled pair
+ 2 + // opening and closing '
+ strings.Count(s, "'") // ' added by ReplaceAll
+ sb.Grow(growLen)
+ sb.WriteString("'")
+ sb.WriteString(strings.ReplaceAll(s, "'", "''"))
+ sb.WriteString("'")
+ return sb.String()
+}
+
+// String string value to text with quote or literal header if required
+func (n *StringNode) String() string {
+ switch n.Token.Type {
+ case token.SingleQuoteType:
+ quoted := escapeSingleQuote(n.Value)
+ if n.Comment != nil {
+ return addCommentString(quoted, n.Comment)
+ }
+ return quoted
+ case token.DoubleQuoteType:
+ quoted := strconv.Quote(n.Value)
+ if n.Comment != nil {
+ return addCommentString(quoted, n.Comment)
+ }
+ return quoted
+ }
+
+ lbc := token.DetectLineBreakCharacter(n.Value)
+ if strings.Contains(n.Value, lbc) {
+ // This block assumes that the line breaks in this inside scalar content and the Outside scalar content are the same.
+ // It works mostly, but inconsistencies occur if line break characters are mixed.
+ header := token.LiteralBlockHeader(n.Value)
+ space := strings.Repeat(" ", n.Token.Position.Column-1)
+ values := []string{}
+ for _, v := range strings.Split(n.Value, lbc) {
+ values = append(values, fmt.Sprintf("%s %s", space, v))
+ }
+ block := strings.TrimSuffix(strings.TrimSuffix(strings.Join(values, lbc), fmt.Sprintf("%s %s", lbc, space)), fmt.Sprintf(" %s", space))
+ return fmt.Sprintf("%s%s%s", header, lbc, block)
+ } else if len(n.Value) > 0 && (n.Value[0] == '{' || n.Value[0] == '[') {
+ return fmt.Sprintf(`'%s'`, n.Value)
+ }
+ if n.Comment != nil {
+ return addCommentString(n.Value, n.Comment)
+ }
+ return n.Value
+}
+
+func (n *StringNode) stringWithoutComment() string {
+ switch n.Token.Type {
+ case token.SingleQuoteType:
+ quoted := fmt.Sprintf(`'%s'`, n.Value)
+ return quoted
+ case token.DoubleQuoteType:
+ quoted := strconv.Quote(n.Value)
+ return quoted
+ }
+
+ lbc := token.DetectLineBreakCharacter(n.Value)
+ if strings.Contains(n.Value, lbc) {
+ // This block assumes that the line breaks in this inside scalar content and the Outside scalar content are the same.
+ // It works mostly, but inconsistencies occur if line break characters are mixed.
+ header := token.LiteralBlockHeader(n.Value)
+ space := strings.Repeat(" ", n.Token.Position.Column-1)
+ values := []string{}
+ for _, v := range strings.Split(n.Value, lbc) {
+ values = append(values, fmt.Sprintf("%s %s", space, v))
+ }
+ block := strings.TrimSuffix(strings.TrimSuffix(strings.Join(values, lbc), fmt.Sprintf("%s %s", lbc, space)), fmt.Sprintf(" %s", space))
+ return fmt.Sprintf("%s%s%s", header, lbc, block)
+ } else if len(n.Value) > 0 && (n.Value[0] == '{' || n.Value[0] == '[') {
+ return fmt.Sprintf(`'%s'`, n.Value)
+ }
+ return n.Value
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *StringNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// LiteralNode type of literal node
+type LiteralNode struct {
+ *BaseNode
+ Start *token.Token
+ Value *StringNode
+}
+
+// Read implements (io.Reader).Read
+func (n *LiteralNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns LiteralType
+func (n *LiteralNode) Type() NodeType { return LiteralType }
+
+// GetToken returns token instance
+func (n *LiteralNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *LiteralNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ if n.Value != nil {
+ n.Value.AddColumn(col)
+ }
+}
+
+// GetValue returns string value
+func (n *LiteralNode) GetValue() interface{} {
+ return n.String()
+}
+
+// String literal to text
+func (n *LiteralNode) String() string {
+ origin := n.Value.GetToken().Origin
+ lit := strings.TrimRight(strings.TrimRight(origin, " "), "\n")
+ if n.Comment != nil {
+ return fmt.Sprintf("%s %s\n%s", n.Start.Value, n.Comment.String(), lit)
+ }
+ return fmt.Sprintf("%s\n%s", n.Start.Value, lit)
+}
+
+func (n *LiteralNode) stringWithoutComment() string {
+ return n.String()
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *LiteralNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// MergeKeyNode type of merge key node
+type MergeKeyNode struct {
+ *BaseNode
+ Token *token.Token
+}
+
+// Read implements (io.Reader).Read
+func (n *MergeKeyNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns MergeKeyType
+func (n *MergeKeyNode) Type() NodeType { return MergeKeyType }
+
+// GetToken returns token instance
+func (n *MergeKeyNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// GetValue returns '<<' value
+func (n *MergeKeyNode) GetValue() interface{} {
+ return n.Token.Value
+}
+
+// String returns '<<' value
+func (n *MergeKeyNode) String() string {
+ return n.Token.Value
+}
+
+func (n *MergeKeyNode) stringWithoutComment() string {
+ return n.Token.Value
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *MergeKeyNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *MergeKeyNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// BoolNode type of boolean node
+type BoolNode struct {
+ *BaseNode
+ Token *token.Token
+ Value bool
+}
+
+// Read implements (io.Reader).Read
+func (n *BoolNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns BoolType
+func (n *BoolNode) Type() NodeType { return BoolType }
+
+// GetToken returns token instance
+func (n *BoolNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *BoolNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// GetValue returns boolean value
+func (n *BoolNode) GetValue() interface{} {
+ return n.Value
+}
+
+// String boolean to text
+func (n *BoolNode) String() string {
+ if n.Comment != nil {
+ return addCommentString(n.Token.Value, n.Comment)
+ }
+ return n.stringWithoutComment()
+}
+
+func (n *BoolNode) stringWithoutComment() string {
+ return n.Token.Value
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *BoolNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// InfinityNode type of infinity node
+type InfinityNode struct {
+ *BaseNode
+ Token *token.Token
+ Value float64
+}
+
+// Read implements (io.Reader).Read
+func (n *InfinityNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns InfinityType
+func (n *InfinityNode) Type() NodeType { return InfinityType }
+
+// GetToken returns token instance
+func (n *InfinityNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *InfinityNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// GetValue returns math.Inf(0) or math.Inf(-1)
+func (n *InfinityNode) GetValue() interface{} {
+ return n.Value
+}
+
+// String infinity to text
+func (n *InfinityNode) String() string {
+ if n.Comment != nil {
+ return addCommentString(n.Token.Value, n.Comment)
+ }
+ return n.stringWithoutComment()
+}
+
+func (n *InfinityNode) stringWithoutComment() string {
+ return n.Token.Value
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *InfinityNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// NanNode type of nan node
+type NanNode struct {
+ *BaseNode
+ Token *token.Token
+}
+
+// Read implements (io.Reader).Read
+func (n *NanNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns NanType
+func (n *NanNode) Type() NodeType { return NanType }
+
+// GetToken returns token instance
+func (n *NanNode) GetToken() *token.Token {
+ return n.Token
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *NanNode) AddColumn(col int) {
+ n.Token.AddColumn(col)
+}
+
+// GetValue returns math.NaN()
+func (n *NanNode) GetValue() interface{} {
+ return math.NaN()
+}
+
+// String returns .nan
+func (n *NanNode) String() string {
+ if n.Comment != nil {
+ return addCommentString(n.Token.Value, n.Comment)
+ }
+ return n.stringWithoutComment()
+}
+
+func (n *NanNode) stringWithoutComment() string {
+ return n.Token.Value
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *NanNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// MapNode interface of MappingValueNode / MappingNode
+type MapNode interface {
+ MapRange() *MapNodeIter
+}
+
+// MapNodeIter is an iterator for ranging over a MapNode
+type MapNodeIter struct {
+ values []*MappingValueNode
+ idx int
+}
+
+const (
+ startRangeIndex = -1
+)
+
+// Next advances the map iterator and reports whether there is another entry.
+// It returns false when the iterator is exhausted.
+func (m *MapNodeIter) Next() bool {
+ m.idx++
+ next := m.idx < len(m.values)
+ return next
+}
+
+// Key returns the key of the iterator's current map node entry.
+func (m *MapNodeIter) Key() Node {
+ return m.values[m.idx].Key
+}
+
+// Value returns the value of the iterator's current map node entry.
+func (m *MapNodeIter) Value() Node {
+ return m.values[m.idx].Value
+}
+
+// MappingNode type of mapping node
+type MappingNode struct {
+ *BaseNode
+ Start *token.Token
+ End *token.Token
+ IsFlowStyle bool
+ Values []*MappingValueNode
+}
+
+func (n *MappingNode) startPos() *token.Position {
+ if len(n.Values) == 0 {
+ return n.Start.Position
+ }
+ return n.Values[0].Key.GetToken().Position
+}
+
+// Merge merge key/value of map.
+func (n *MappingNode) Merge(target *MappingNode) {
+ keyToMapValueMap := map[string]*MappingValueNode{}
+ for _, value := range n.Values {
+ key := value.Key.String()
+ keyToMapValueMap[key] = value
+ }
+ column := n.startPos().Column - target.startPos().Column
+ target.AddColumn(column)
+ for _, value := range target.Values {
+ mapValue, exists := keyToMapValueMap[value.Key.String()]
+ if exists {
+ mapValue.Value = value.Value
+ } else {
+ n.Values = append(n.Values, value)
+ }
+ }
+}
+
+// SetIsFlowStyle set value to IsFlowStyle field recursively.
+func (n *MappingNode) SetIsFlowStyle(isFlow bool) {
+ n.IsFlowStyle = isFlow
+ for _, value := range n.Values {
+ value.SetIsFlowStyle(isFlow)
+ }
+}
+
+// Read implements (io.Reader).Read
+func (n *MappingNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns MappingType
+func (n *MappingNode) Type() NodeType { return MappingType }
+
+// GetToken returns token instance
+func (n *MappingNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *MappingNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ n.End.AddColumn(col)
+ for _, value := range n.Values {
+ value.AddColumn(col)
+ }
+}
+
+func (n *MappingNode) flowStyleString(commentMode bool) string {
+ values := []string{}
+ for _, value := range n.Values {
+ values = append(values, strings.TrimLeft(value.String(), " "))
+ }
+ mapText := fmt.Sprintf("{%s}", strings.Join(values, ", "))
+ if commentMode && n.Comment != nil {
+ return addCommentString(mapText, n.Comment)
+ }
+ return mapText
+}
+
+func (n *MappingNode) blockStyleString(commentMode bool) string {
+ values := []string{}
+ for _, value := range n.Values {
+ values = append(values, value.String())
+ }
+ mapText := strings.Join(values, "\n")
+ if commentMode && n.Comment != nil {
+ value := values[0]
+ var spaceNum int
+ for i := 0; i < len(value); i++ {
+ if value[i] != ' ' {
+ break
+ }
+ spaceNum++
+ }
+ comment := n.Comment.StringWithSpace(spaceNum)
+ return fmt.Sprintf("%s\n%s", comment, mapText)
+ }
+ return mapText
+}
+
+// String mapping values to text
+func (n *MappingNode) String() string {
+ if len(n.Values) == 0 {
+ if n.Comment != nil {
+ return addCommentString("{}", n.Comment)
+ }
+ return "{}"
+ }
+
+ commentMode := true
+ if n.IsFlowStyle || len(n.Values) == 0 {
+ return n.flowStyleString(commentMode)
+ }
+ return n.blockStyleString(commentMode)
+}
+
+func (n *MappingNode) stringWithoutComment() string {
+ commentMode := false
+ if n.IsFlowStyle || len(n.Values) == 0 {
+ return n.flowStyleString(commentMode)
+ }
+ return n.blockStyleString(commentMode)
+}
+
+// MapRange implements MapNode protocol
+func (n *MappingNode) MapRange() *MapNodeIter {
+ return &MapNodeIter{
+ idx: startRangeIndex,
+ values: n.Values,
+ }
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *MappingNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// MappingKeyNode type of tag node
+type MappingKeyNode struct {
+ *BaseNode
+ Start *token.Token
+ Value Node
+}
+
+// Read implements (io.Reader).Read
+func (n *MappingKeyNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns MappingKeyType
+func (n *MappingKeyNode) Type() NodeType { return MappingKeyType }
+
+// GetToken returns token instance
+func (n *MappingKeyNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *MappingKeyNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ if n.Value != nil {
+ n.Value.AddColumn(col)
+ }
+}
+
+// String tag to text
+func (n *MappingKeyNode) String() string {
+ return fmt.Sprintf("%s %s", n.Start.Value, n.Value.String())
+}
+
+func (n *MappingKeyNode) stringWithoutComment() string {
+ return fmt.Sprintf("%s %s", n.Start.Value, n.Value.String())
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *MappingKeyNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// MappingValueNode type of mapping value
+type MappingValueNode struct {
+ *BaseNode
+ Start *token.Token
+ Key Node
+ Value Node
+}
+
+// Replace replace value node.
+func (n *MappingValueNode) Replace(value Node) error {
+ column := n.Value.GetToken().Position.Column - value.GetToken().Position.Column
+ value.AddColumn(column)
+ n.Value = value
+ return nil
+}
+
+// Read implements (io.Reader).Read
+func (n *MappingValueNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns MappingValueType
+func (n *MappingValueNode) Type() NodeType { return MappingValueType }
+
+// GetToken returns token instance
+func (n *MappingValueNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *MappingValueNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ if n.Key != nil {
+ n.Key.AddColumn(col)
+ }
+ if n.Value != nil {
+ n.Value.AddColumn(col)
+ }
+}
+
+// SetIsFlowStyle set value to IsFlowStyle field recursively.
+func (n *MappingValueNode) SetIsFlowStyle(isFlow bool) {
+ switch value := n.Value.(type) {
+ case *MappingNode:
+ value.SetIsFlowStyle(isFlow)
+ case *MappingValueNode:
+ value.SetIsFlowStyle(isFlow)
+ case *SequenceNode:
+ value.SetIsFlowStyle(isFlow)
+ }
+}
+
+// String mapping value to text
+func (n *MappingValueNode) String() string {
+ if n.Comment != nil {
+ return fmt.Sprintf(
+ "%s\n%s",
+ n.Comment.StringWithSpace(n.Key.GetToken().Position.Column-1),
+ n.toString(),
+ )
+ }
+ return n.toString()
+}
+
+func (n *MappingValueNode) toString() string {
+ space := strings.Repeat(" ", n.Key.GetToken().Position.Column-1)
+ keyIndentLevel := n.Key.GetToken().Position.IndentLevel
+ valueIndentLevel := n.Value.GetToken().Position.IndentLevel
+ keyComment := n.Key.GetComment()
+ if _, ok := n.Value.(ScalarNode); ok {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if keyIndentLevel < valueIndentLevel {
+ if keyComment != nil {
+ return fmt.Sprintf(
+ "%s%s: %s\n%s",
+ space,
+ n.Key.stringWithoutComment(),
+ keyComment.String(),
+ n.Value.String(),
+ )
+ }
+ return fmt.Sprintf("%s%s:\n%s", space, n.Key.String(), n.Value.String())
+ } else if m, ok := n.Value.(*MappingNode); ok && (m.IsFlowStyle || len(m.Values) == 0) {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if s, ok := n.Value.(*SequenceNode); ok && (s.IsFlowStyle || len(s.Values) == 0) {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if _, ok := n.Value.(*AnchorNode); ok {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if _, ok := n.Value.(*AliasNode); ok {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ }
+ if keyComment != nil {
+ return fmt.Sprintf(
+ "%s%s: %s\n%s",
+ space,
+ n.Key.stringWithoutComment(),
+ keyComment.String(),
+ n.Value.String(),
+ )
+ }
+ if m, ok := n.Value.(*MappingNode); ok && m.Comment != nil {
+ return fmt.Sprintf(
+ "%s%s: %s",
+ space,
+ n.Key.String(),
+ strings.TrimLeft(n.Value.String(), " "),
+ )
+ }
+ return fmt.Sprintf("%s%s:\n%s", space, n.Key.String(), n.Value.String())
+}
+
+func (n *MappingValueNode) stringWithoutComment() string {
+ space := strings.Repeat(" ", n.Key.GetToken().Position.Column-1)
+ keyIndentLevel := n.Key.GetToken().Position.IndentLevel
+ valueIndentLevel := n.Value.GetToken().Position.IndentLevel
+ if _, ok := n.Value.(ScalarNode); ok {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if keyIndentLevel < valueIndentLevel {
+ return fmt.Sprintf("%s%s:\n%s", space, n.Key.String(), n.Value.String())
+ } else if m, ok := n.Value.(*MappingNode); ok && (m.IsFlowStyle || len(m.Values) == 0) {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if s, ok := n.Value.(*SequenceNode); ok && (s.IsFlowStyle || len(s.Values) == 0) {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if _, ok := n.Value.(*AnchorNode); ok {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ } else if _, ok := n.Value.(*AliasNode); ok {
+ return fmt.Sprintf("%s%s: %s", space, n.Key.String(), n.Value.String())
+ }
+ return fmt.Sprintf("%s%s:\n%s", space, n.Key.String(), n.Value.String())
+}
+
+// MapRange implements MapNode protocol
+func (n *MappingValueNode) MapRange() *MapNodeIter {
+ return &MapNodeIter{
+ idx: startRangeIndex,
+ values: []*MappingValueNode{n},
+ }
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *MappingValueNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// ArrayNode interface of SequenceNode
+type ArrayNode interface {
+ ArrayRange() *ArrayNodeIter
+}
+
+// ArrayNodeIter is an iterator for ranging over a ArrayNode
+type ArrayNodeIter struct {
+ values []Node
+ idx int
+}
+
+// Next advances the array iterator and reports whether there is another entry.
+// It returns false when the iterator is exhausted.
+func (m *ArrayNodeIter) Next() bool {
+ m.idx++
+ next := m.idx < len(m.values)
+ return next
+}
+
+// Value returns the value of the iterator's current array entry.
+func (m *ArrayNodeIter) Value() Node {
+ return m.values[m.idx]
+}
+
+// Len returns length of array
+func (m *ArrayNodeIter) Len() int {
+ return len(m.values)
+}
+
+// SequenceNode type of sequence node
+type SequenceNode struct {
+ *BaseNode
+ Start *token.Token
+ End *token.Token
+ IsFlowStyle bool
+ Values []Node
+ ValueComments []*CommentGroupNode
+}
+
+// Replace replace value node.
+func (n *SequenceNode) Replace(idx int, value Node) error {
+ if len(n.Values) <= idx {
+ return xerrors.Errorf(
+ "invalid index for sequence: sequence length is %d, but specified %d index",
+ len(n.Values), idx,
+ )
+ }
+ column := n.Values[idx].GetToken().Position.Column - value.GetToken().Position.Column
+ value.AddColumn(column)
+ n.Values[idx] = value
+ return nil
+}
+
+// Merge merge sequence value.
+func (n *SequenceNode) Merge(target *SequenceNode) {
+ column := n.Start.Position.Column - target.Start.Position.Column
+ target.AddColumn(column)
+ for _, value := range target.Values {
+ n.Values = append(n.Values, value)
+ }
+}
+
+// SetIsFlowStyle set value to IsFlowStyle field recursively.
+func (n *SequenceNode) SetIsFlowStyle(isFlow bool) {
+ n.IsFlowStyle = isFlow
+ for _, value := range n.Values {
+ switch value := value.(type) {
+ case *MappingNode:
+ value.SetIsFlowStyle(isFlow)
+ case *MappingValueNode:
+ value.SetIsFlowStyle(isFlow)
+ case *SequenceNode:
+ value.SetIsFlowStyle(isFlow)
+ }
+ }
+}
+
+// Read implements (io.Reader).Read
+func (n *SequenceNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns SequenceType
+func (n *SequenceNode) Type() NodeType { return SequenceType }
+
+// GetToken returns token instance
+func (n *SequenceNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *SequenceNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ n.End.AddColumn(col)
+ for _, value := range n.Values {
+ value.AddColumn(col)
+ }
+}
+
+func (n *SequenceNode) flowStyleString() string {
+ values := []string{}
+ for _, value := range n.Values {
+ values = append(values, value.String())
+ }
+ return fmt.Sprintf("[%s]", strings.Join(values, ", "))
+}
+
+func (n *SequenceNode) blockStyleString() string {
+ space := strings.Repeat(" ", n.Start.Position.Column-1)
+ values := []string{}
+ if n.Comment != nil {
+ values = append(values, n.Comment.StringWithSpace(n.Start.Position.Column-1))
+ }
+
+ for idx, value := range n.Values {
+ valueStr := value.String()
+ splittedValues := strings.Split(valueStr, "\n")
+ trimmedFirstValue := strings.TrimLeft(splittedValues[0], " ")
+ diffLength := len(splittedValues[0]) - len(trimmedFirstValue)
+ if len(splittedValues) > 1 && value.Type() == StringType || value.Type() == LiteralType {
+ // If multi-line string, the space characters for indent have already been added, so delete them.
+ for i := 1; i < len(splittedValues); i++ {
+ splittedValues[i] = strings.TrimLeft(splittedValues[i], " ")
+ }
+ }
+ newValues := []string{trimmedFirstValue}
+ for i := 1; i < len(splittedValues); i++ {
+ if len(splittedValues[i]) <= diffLength {
+ // this line is \n or white space only
+ newValues = append(newValues, "")
+ continue
+ }
+ trimmed := splittedValues[i][diffLength:]
+ newValues = append(newValues, fmt.Sprintf("%s %s", space, trimmed))
+ }
+ newValue := strings.Join(newValues, "\n")
+ if len(n.ValueComments) == len(n.Values) && n.ValueComments[idx] != nil {
+ values = append(values, n.ValueComments[idx].StringWithSpace(n.Start.Position.Column-1))
+ }
+ values = append(values, fmt.Sprintf("%s- %s", space, newValue))
+ }
+ return strings.Join(values, "\n")
+}
+
+// String sequence to text
+func (n *SequenceNode) String() string {
+ if n.IsFlowStyle || len(n.Values) == 0 {
+ return n.flowStyleString()
+ }
+ return n.blockStyleString()
+}
+
+func (n *SequenceNode) stringWithoutComment() string {
+ if n.IsFlowStyle || len(n.Values) == 0 {
+ return n.flowStyleString()
+ }
+ return n.blockStyleString()
+}
+
+// ArrayRange implements ArrayNode protocol
+func (n *SequenceNode) ArrayRange() *ArrayNodeIter {
+ return &ArrayNodeIter{
+ idx: startRangeIndex,
+ values: n.Values,
+ }
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *SequenceNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// AnchorNode type of anchor node
+type AnchorNode struct {
+ *BaseNode
+ Start *token.Token
+ Name Node
+ Value Node
+}
+
+func (n *AnchorNode) SetName(name string) error {
+ if n.Name == nil {
+ return ErrInvalidAnchorName
+ }
+ s, ok := n.Name.(*StringNode)
+ if !ok {
+ return ErrInvalidAnchorName
+ }
+ s.Value = name
+ return nil
+}
+
+// Read implements (io.Reader).Read
+func (n *AnchorNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns AnchorType
+func (n *AnchorNode) Type() NodeType { return AnchorType }
+
+// GetToken returns token instance
+func (n *AnchorNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *AnchorNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ if n.Name != nil {
+ n.Name.AddColumn(col)
+ }
+ if n.Value != nil {
+ n.Value.AddColumn(col)
+ }
+}
+
+// String anchor to text
+func (n *AnchorNode) String() string {
+ value := n.Value.String()
+ if len(strings.Split(value, "\n")) > 1 {
+ return fmt.Sprintf("&%s\n%s", n.Name.String(), value)
+ } else if s, ok := n.Value.(*SequenceNode); ok && !s.IsFlowStyle {
+ return fmt.Sprintf("&%s\n%s", n.Name.String(), value)
+ } else if m, ok := n.Value.(*MappingNode); ok && !m.IsFlowStyle {
+ return fmt.Sprintf("&%s\n%s", n.Name.String(), value)
+ }
+ return fmt.Sprintf("&%s %s", n.Name.String(), value)
+}
+
+func (n *AnchorNode) stringWithoutComment() string {
+ return n.String()
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *AnchorNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// AliasNode type of alias node
+type AliasNode struct {
+ *BaseNode
+ Start *token.Token
+ Value Node
+}
+
+func (n *AliasNode) SetName(name string) error {
+ if n.Value == nil {
+ return ErrInvalidAliasName
+ }
+ s, ok := n.Value.(*StringNode)
+ if !ok {
+ return ErrInvalidAliasName
+ }
+ s.Value = name
+ return nil
+}
+
+// Read implements (io.Reader).Read
+func (n *AliasNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns AliasType
+func (n *AliasNode) Type() NodeType { return AliasType }
+
+// GetToken returns token instance
+func (n *AliasNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *AliasNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ if n.Value != nil {
+ n.Value.AddColumn(col)
+ }
+}
+
+// String alias to text
+func (n *AliasNode) String() string {
+ return fmt.Sprintf("*%s", n.Value.String())
+}
+
+func (n *AliasNode) stringWithoutComment() string {
+ return fmt.Sprintf("*%s", n.Value.String())
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *AliasNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// DirectiveNode type of directive node
+type DirectiveNode struct {
+ *BaseNode
+ Start *token.Token
+ Value Node
+}
+
+// Read implements (io.Reader).Read
+func (n *DirectiveNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns DirectiveType
+func (n *DirectiveNode) Type() NodeType { return DirectiveType }
+
+// GetToken returns token instance
+func (n *DirectiveNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *DirectiveNode) AddColumn(col int) {
+ if n.Value != nil {
+ n.Value.AddColumn(col)
+ }
+}
+
+// String directive to text
+func (n *DirectiveNode) String() string {
+ return fmt.Sprintf("%s%s", n.Start.Value, n.Value.String())
+}
+
+func (n *DirectiveNode) stringWithoutComment() string {
+ return fmt.Sprintf("%s%s", n.Start.Value, n.Value.String())
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *DirectiveNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// TagNode type of tag node
+type TagNode struct {
+ *BaseNode
+ Start *token.Token
+ Value Node
+}
+
+// Read implements (io.Reader).Read
+func (n *TagNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns TagType
+func (n *TagNode) Type() NodeType { return TagType }
+
+// GetToken returns token instance
+func (n *TagNode) GetToken() *token.Token {
+ return n.Start
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *TagNode) AddColumn(col int) {
+ n.Start.AddColumn(col)
+ if n.Value != nil {
+ n.Value.AddColumn(col)
+ }
+}
+
+// String tag to text
+func (n *TagNode) String() string {
+ return fmt.Sprintf("%s %s", n.Start.Value, n.Value.String())
+}
+
+func (n *TagNode) stringWithoutComment() string {
+ return fmt.Sprintf("%s %s", n.Start.Value, n.Value.String())
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *TagNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// CommentNode type of comment node
+type CommentNode struct {
+ *BaseNode
+ Token *token.Token
+}
+
+// Read implements (io.Reader).Read
+func (n *CommentNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns TagType
+func (n *CommentNode) Type() NodeType { return CommentType }
+
+// GetToken returns token instance
+func (n *CommentNode) GetToken() *token.Token { return n.Token }
+
+// AddColumn add column number to child nodes recursively
+func (n *CommentNode) AddColumn(col int) {
+ if n.Token == nil {
+ return
+ }
+ n.Token.AddColumn(col)
+}
+
+// String comment to text
+func (n *CommentNode) String() string {
+ return fmt.Sprintf("#%s", n.Token.Value)
+}
+
+func (n *CommentNode) stringWithoutComment() string {
+ return ""
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *CommentNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// CommentGroupNode type of comment node
+type CommentGroupNode struct {
+ *BaseNode
+ Comments []*CommentNode
+}
+
+// Read implements (io.Reader).Read
+func (n *CommentGroupNode) Read(p []byte) (int, error) {
+ return readNode(p, n)
+}
+
+// Type returns TagType
+func (n *CommentGroupNode) Type() NodeType { return CommentType }
+
+// GetToken returns token instance
+func (n *CommentGroupNode) GetToken() *token.Token {
+ if len(n.Comments) > 0 {
+ return n.Comments[0].Token
+ }
+ return nil
+}
+
+// AddColumn add column number to child nodes recursively
+func (n *CommentGroupNode) AddColumn(col int) {
+ for _, comment := range n.Comments {
+ comment.AddColumn(col)
+ }
+}
+
+// String comment to text
+func (n *CommentGroupNode) String() string {
+ values := []string{}
+ for _, comment := range n.Comments {
+ values = append(values, comment.String())
+ }
+ return strings.Join(values, "\n")
+}
+
+func (n *CommentGroupNode) StringWithSpace(col int) string {
+ space := strings.Repeat(" ", col)
+ values := []string{}
+ for _, comment := range n.Comments {
+ values = append(values, space+comment.String())
+ }
+ return strings.Join(values, "\n")
+
+}
+
+func (n *CommentGroupNode) stringWithoutComment() string {
+ return ""
+}
+
+// MarshalYAML encodes to a YAML text
+func (n *CommentGroupNode) MarshalYAML() ([]byte, error) {
+ return []byte(n.String()), nil
+}
+
+// Visitor has Visit method that is invokded for each node encountered by Walk.
+// If the result visitor w is not nil, Walk visits each of the children of node with the visitor w,
+// followed by a call of w.Visit(nil).
+type Visitor interface {
+ Visit(Node) Visitor
+}
+
+// Walk traverses an AST in depth-first order: It starts by calling v.Visit(node); node must not be nil.
+// If the visitor w returned by v.Visit(node) is not nil,
+// Walk is invoked recursively with visitor w for each of the non-nil children of node,
+// followed by a call of w.Visit(nil).
+func Walk(v Visitor, node Node) {
+ if v = v.Visit(node); v == nil {
+ return
+ }
+
+ switch n := node.(type) {
+ case *CommentNode:
+ case *NullNode:
+ walkComment(v, n.BaseNode)
+ case *IntegerNode:
+ walkComment(v, n.BaseNode)
+ case *FloatNode:
+ walkComment(v, n.BaseNode)
+ case *StringNode:
+ walkComment(v, n.BaseNode)
+ case *MergeKeyNode:
+ walkComment(v, n.BaseNode)
+ case *BoolNode:
+ walkComment(v, n.BaseNode)
+ case *InfinityNode:
+ walkComment(v, n.BaseNode)
+ case *NanNode:
+ walkComment(v, n.BaseNode)
+ case *LiteralNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Value)
+ case *DirectiveNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Value)
+ case *TagNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Value)
+ case *DocumentNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Body)
+ case *MappingNode:
+ walkComment(v, n.BaseNode)
+ for _, value := range n.Values {
+ Walk(v, value)
+ }
+ case *MappingKeyNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Value)
+ case *MappingValueNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Key)
+ Walk(v, n.Value)
+ case *SequenceNode:
+ walkComment(v, n.BaseNode)
+ for _, value := range n.Values {
+ Walk(v, value)
+ }
+ case *AnchorNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Name)
+ Walk(v, n.Value)
+ case *AliasNode:
+ walkComment(v, n.BaseNode)
+ Walk(v, n.Value)
+ }
+}
+
+func walkComment(v Visitor, base *BaseNode) {
+ if base == nil {
+ return
+ }
+ if base.Comment == nil {
+ return
+ }
+ Walk(v, base.Comment)
+}
+
+type filterWalker struct {
+ typ NodeType
+ results []Node
+}
+
+func (v *filterWalker) Visit(n Node) Visitor {
+ if v.typ == n.Type() {
+ v.results = append(v.results, n)
+ }
+ return v
+}
+
+type parentFinder struct {
+ target Node
+}
+
+func (f *parentFinder) walk(parent, node Node) Node {
+ if f.target == node {
+ return parent
+ }
+ switch n := node.(type) {
+ case *CommentNode:
+ return nil
+ case *NullNode:
+ return nil
+ case *IntegerNode:
+ return nil
+ case *FloatNode:
+ return nil
+ case *StringNode:
+ return nil
+ case *MergeKeyNode:
+ return nil
+ case *BoolNode:
+ return nil
+ case *InfinityNode:
+ return nil
+ case *NanNode:
+ return nil
+ case *LiteralNode:
+ return f.walk(node, n.Value)
+ case *DirectiveNode:
+ return f.walk(node, n.Value)
+ case *TagNode:
+ return f.walk(node, n.Value)
+ case *DocumentNode:
+ return f.walk(node, n.Body)
+ case *MappingNode:
+ for _, value := range n.Values {
+ if found := f.walk(node, value); found != nil {
+ return found
+ }
+ }
+ case *MappingKeyNode:
+ return f.walk(node, n.Value)
+ case *MappingValueNode:
+ if found := f.walk(node, n.Key); found != nil {
+ return found
+ }
+ return f.walk(node, n.Value)
+ case *SequenceNode:
+ for _, value := range n.Values {
+ if found := f.walk(node, value); found != nil {
+ return found
+ }
+ }
+ case *AnchorNode:
+ if found := f.walk(node, n.Name); found != nil {
+ return found
+ }
+ return f.walk(node, n.Value)
+ case *AliasNode:
+ return f.walk(node, n.Value)
+ }
+ return nil
+}
+
+// Parent get parent node from child node.
+func Parent(root, child Node) Node {
+ finder := &parentFinder{target: child}
+ return finder.walk(root, root)
+}
+
+// Filter returns a list of nodes that match the given type.
+func Filter(typ NodeType, node Node) []Node {
+ walker := &filterWalker{typ: typ}
+ Walk(walker, node)
+ return walker.results
+}
+
+// FilterFile returns a list of nodes that match the given type.
+func FilterFile(typ NodeType, file *File) []Node {
+ results := []Node{}
+ for _, doc := range file.Docs {
+ walker := &filterWalker{typ: typ}
+ Walk(walker, doc)
+ results = append(results, walker.results...)
+ }
+ return results
+}
+
+type ErrInvalidMergeType struct {
+ dst Node
+ src Node
+}
+
+func (e *ErrInvalidMergeType) Error() string {
+ return fmt.Sprintf("cannot merge %s into %s", e.src.Type(), e.dst.Type())
+}
+
+// Merge merge document, map, sequence node.
+func Merge(dst Node, src Node) error {
+ if doc, ok := src.(*DocumentNode); ok {
+ src = doc.Body
+ }
+ err := &ErrInvalidMergeType{dst: dst, src: src}
+ switch dst.Type() {
+ case DocumentType:
+ node := dst.(*DocumentNode)
+ return Merge(node.Body, src)
+ case MappingType:
+ node := dst.(*MappingNode)
+ target, ok := src.(*MappingNode)
+ if !ok {
+ return err
+ }
+ node.Merge(target)
+ return nil
+ case SequenceType:
+ node := dst.(*SequenceNode)
+ target, ok := src.(*SequenceNode)
+ if !ok {
+ return err
+ }
+ node.Merge(target)
+ return nil
+ }
+ return err
+}
diff --git a/vendor/github.com/goccy/go-yaml/decode.go b/vendor/github.com/goccy/go-yaml/decode.go
new file mode 100644
index 0000000..5d1f63a
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/decode.go
@@ -0,0 +1,1584 @@
+package yaml
+
+import (
+ "bytes"
+ "context"
+ "encoding"
+ "encoding/base64"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "math"
+ "os"
+ "path/filepath"
+ "reflect"
+ "strconv"
+ "time"
+
+ "github.com/goccy/go-yaml/ast"
+ "github.com/goccy/go-yaml/internal/errors"
+ "github.com/goccy/go-yaml/parser"
+ "github.com/goccy/go-yaml/token"
+ "golang.org/x/xerrors"
+)
+
+// Decoder reads and decodes YAML values from an input stream.
+type Decoder struct {
+ reader io.Reader
+ referenceReaders []io.Reader
+ anchorNodeMap map[string]ast.Node
+ anchorValueMap map[string]reflect.Value
+ toCommentMap CommentMap
+ opts []DecodeOption
+ referenceFiles []string
+ referenceDirs []string
+ isRecursiveDir bool
+ isResolvedReference bool
+ validator StructValidator
+ disallowUnknownField bool
+ disallowDuplicateKey bool
+ useOrderedMap bool
+ useJSONUnmarshaler bool
+ parsedFile *ast.File
+ streamIndex int
+}
+
+// NewDecoder returns a new decoder that reads from r.
+func NewDecoder(r io.Reader, opts ...DecodeOption) *Decoder {
+ return &Decoder{
+ reader: r,
+ anchorNodeMap: map[string]ast.Node{},
+ anchorValueMap: map[string]reflect.Value{},
+ opts: opts,
+ referenceReaders: []io.Reader{},
+ referenceFiles: []string{},
+ referenceDirs: []string{},
+ isRecursiveDir: false,
+ isResolvedReference: false,
+ disallowUnknownField: false,
+ disallowDuplicateKey: false,
+ useOrderedMap: false,
+ }
+}
+
+func (d *Decoder) castToFloat(v interface{}) interface{} {
+ switch vv := v.(type) {
+ case int:
+ return float64(vv)
+ case int8:
+ return float64(vv)
+ case int16:
+ return float64(vv)
+ case int32:
+ return float64(vv)
+ case int64:
+ return float64(vv)
+ case uint:
+ return float64(vv)
+ case uint8:
+ return float64(vv)
+ case uint16:
+ return float64(vv)
+ case uint32:
+ return float64(vv)
+ case uint64:
+ return float64(vv)
+ case float32:
+ return float64(vv)
+ case float64:
+ return vv
+ case string:
+ // if error occurred, return zero value
+ f, _ := strconv.ParseFloat(vv, 64)
+ return f
+ }
+ return 0
+}
+
+func (d *Decoder) mergeValueNode(value ast.Node) ast.Node {
+ if value.Type() == ast.AliasType {
+ aliasNode := value.(*ast.AliasNode)
+ aliasName := aliasNode.Value.GetToken().Value
+ return d.anchorNodeMap[aliasName]
+ }
+ return value
+}
+
+func (d *Decoder) mapKeyNodeToString(node ast.Node) string {
+ key := d.nodeToValue(node)
+ if key == nil {
+ return "null"
+ }
+ if k, ok := key.(string); ok {
+ return k
+ }
+ return fmt.Sprint(key)
+}
+
+func (d *Decoder) setToMapValue(node ast.Node, m map[string]interface{}) {
+ d.setPathToCommentMap(node)
+ switch n := node.(type) {
+ case *ast.MappingValueNode:
+ if n.Key.Type() == ast.MergeKeyType {
+ d.setToMapValue(d.mergeValueNode(n.Value), m)
+ } else {
+ key := d.mapKeyNodeToString(n.Key)
+ m[key] = d.nodeToValue(n.Value)
+ }
+ case *ast.MappingNode:
+ for _, value := range n.Values {
+ d.setToMapValue(value, m)
+ }
+ case *ast.AnchorNode:
+ anchorName := n.Name.GetToken().Value
+ d.anchorNodeMap[anchorName] = n.Value
+ }
+}
+
+func (d *Decoder) setToOrderedMapValue(node ast.Node, m *MapSlice) {
+ switch n := node.(type) {
+ case *ast.MappingValueNode:
+ if n.Key.Type() == ast.MergeKeyType {
+ d.setToOrderedMapValue(d.mergeValueNode(n.Value), m)
+ } else {
+ key := d.mapKeyNodeToString(n.Key)
+ *m = append(*m, MapItem{Key: key, Value: d.nodeToValue(n.Value)})
+ }
+ case *ast.MappingNode:
+ for _, value := range n.Values {
+ d.setToOrderedMapValue(value, m)
+ }
+ }
+}
+
+func (d *Decoder) setPathToCommentMap(node ast.Node) {
+ if d.toCommentMap == nil {
+ return
+ }
+ commentGroup := node.GetComment()
+ if commentGroup == nil {
+ return
+ }
+ texts := []string{}
+ for _, comment := range commentGroup.Comments {
+ texts = append(texts, comment.Token.Value)
+ }
+ if len(texts) == 0 {
+ return
+ }
+ if len(texts) == 1 {
+ d.toCommentMap[node.GetPath()] = LineComment(texts[0])
+ } else {
+ d.toCommentMap[node.GetPath()] = HeadComment(texts...)
+ }
+}
+
+func (d *Decoder) nodeToValue(node ast.Node) interface{} {
+ d.setPathToCommentMap(node)
+ switch n := node.(type) {
+ case *ast.NullNode:
+ return nil
+ case *ast.StringNode:
+ return n.GetValue()
+ case *ast.IntegerNode:
+ return n.GetValue()
+ case *ast.FloatNode:
+ return n.GetValue()
+ case *ast.BoolNode:
+ return n.GetValue()
+ case *ast.InfinityNode:
+ return n.GetValue()
+ case *ast.NanNode:
+ return n.GetValue()
+ case *ast.TagNode:
+ switch token.ReservedTagKeyword(n.Start.Value) {
+ case token.TimestampTag:
+ t, _ := d.castToTime(n.Value)
+ return t
+ case token.IntegerTag:
+ i, _ := strconv.Atoi(fmt.Sprint(d.nodeToValue(n.Value)))
+ return i
+ case token.FloatTag:
+ return d.castToFloat(d.nodeToValue(n.Value))
+ case token.NullTag:
+ return nil
+ case token.BinaryTag:
+ b, _ := base64.StdEncoding.DecodeString(d.nodeToValue(n.Value).(string))
+ return b
+ case token.StringTag:
+ return d.nodeToValue(n.Value)
+ case token.MappingTag:
+ return d.nodeToValue(n.Value)
+ }
+ case *ast.AnchorNode:
+ anchorName := n.Name.GetToken().Value
+ anchorValue := d.nodeToValue(n.Value)
+ d.anchorNodeMap[anchorName] = n.Value
+ return anchorValue
+ case *ast.AliasNode:
+ aliasName := n.Value.GetToken().Value
+ node := d.anchorNodeMap[aliasName]
+ return d.nodeToValue(node)
+ case *ast.LiteralNode:
+ return n.Value.GetValue()
+ case *ast.MappingKeyNode:
+ return d.nodeToValue(n.Value)
+ case *ast.MappingValueNode:
+ if n.Key.Type() == ast.MergeKeyType {
+ value := d.mergeValueNode(n.Value)
+ if d.useOrderedMap {
+ m := MapSlice{}
+ d.setToOrderedMapValue(value, &m)
+ return m
+ }
+ m := map[string]interface{}{}
+ d.setToMapValue(value, m)
+ return m
+ }
+ key := d.mapKeyNodeToString(n.Key)
+ if d.useOrderedMap {
+ return MapSlice{{Key: key, Value: d.nodeToValue(n.Value)}}
+ }
+ return map[string]interface{}{
+ key: d.nodeToValue(n.Value),
+ }
+ case *ast.MappingNode:
+ if d.useOrderedMap {
+ m := make(MapSlice, 0, len(n.Values))
+ for _, value := range n.Values {
+ d.setToOrderedMapValue(value, &m)
+ }
+ return m
+ }
+ m := make(map[string]interface{}, len(n.Values))
+ for _, value := range n.Values {
+ d.setToMapValue(value, m)
+ }
+ return m
+ case *ast.SequenceNode:
+ v := make([]interface{}, 0, len(n.Values))
+ for _, value := range n.Values {
+ v = append(v, d.nodeToValue(value))
+ }
+ return v
+ }
+ return nil
+}
+
+func (d *Decoder) resolveAlias(node ast.Node) ast.Node {
+ switch n := node.(type) {
+ case *ast.MappingNode:
+ for idx, value := range n.Values {
+ n.Values[idx] = d.resolveAlias(value).(*ast.MappingValueNode)
+ }
+ case *ast.TagNode:
+ n.Value = d.resolveAlias(n.Value)
+ case *ast.MappingKeyNode:
+ n.Value = d.resolveAlias(n.Value)
+ case *ast.MappingValueNode:
+ if n.Key.Type() == ast.MergeKeyType && n.Value.Type() == ast.AliasType {
+ value := d.resolveAlias(n.Value)
+ keyColumn := n.Key.GetToken().Position.Column
+ requiredColumn := keyColumn + 2
+ value.AddColumn(requiredColumn)
+ n.Value = value
+ } else {
+ n.Key = d.resolveAlias(n.Key)
+ n.Value = d.resolveAlias(n.Value)
+ }
+ case *ast.SequenceNode:
+ for idx, value := range n.Values {
+ n.Values[idx] = d.resolveAlias(value)
+ }
+ case *ast.AliasNode:
+ aliasName := n.Value.GetToken().Value
+ return d.resolveAlias(d.anchorNodeMap[aliasName])
+ }
+ return node
+}
+
+func (d *Decoder) getMapNode(node ast.Node) (ast.MapNode, error) {
+ if _, ok := node.(*ast.NullNode); ok {
+ return nil, nil
+ }
+ if anchor, ok := node.(*ast.AnchorNode); ok {
+ mapNode, ok := anchor.Value.(ast.MapNode)
+ if ok {
+ return mapNode, nil
+ }
+ return nil, errUnexpectedNodeType(anchor.Value.Type(), ast.MappingType, node.GetToken())
+ }
+ if alias, ok := node.(*ast.AliasNode); ok {
+ aliasName := alias.Value.GetToken().Value
+ node := d.anchorNodeMap[aliasName]
+ if node == nil {
+ return nil, xerrors.Errorf("cannot find anchor by alias name %s", aliasName)
+ }
+ mapNode, ok := node.(ast.MapNode)
+ if ok {
+ return mapNode, nil
+ }
+ return nil, errUnexpectedNodeType(node.Type(), ast.MappingType, node.GetToken())
+ }
+ mapNode, ok := node.(ast.MapNode)
+ if !ok {
+ return nil, errUnexpectedNodeType(node.Type(), ast.MappingType, node.GetToken())
+ }
+ return mapNode, nil
+}
+
+func (d *Decoder) getArrayNode(node ast.Node) (ast.ArrayNode, error) {
+ if _, ok := node.(*ast.NullNode); ok {
+ return nil, nil
+ }
+ if anchor, ok := node.(*ast.AnchorNode); ok {
+ arrayNode, ok := anchor.Value.(ast.ArrayNode)
+ if ok {
+ return arrayNode, nil
+ }
+
+ return nil, errUnexpectedNodeType(anchor.Value.Type(), ast.SequenceType, node.GetToken())
+ }
+ if alias, ok := node.(*ast.AliasNode); ok {
+ aliasName := alias.Value.GetToken().Value
+ node := d.anchorNodeMap[aliasName]
+ if node == nil {
+ return nil, xerrors.Errorf("cannot find anchor by alias name %s", aliasName)
+ }
+ arrayNode, ok := node.(ast.ArrayNode)
+ if ok {
+ return arrayNode, nil
+ }
+ return nil, errUnexpectedNodeType(node.Type(), ast.SequenceType, node.GetToken())
+ }
+ arrayNode, ok := node.(ast.ArrayNode)
+ if !ok {
+ return nil, errUnexpectedNodeType(node.Type(), ast.SequenceType, node.GetToken())
+ }
+ return arrayNode, nil
+}
+
+func (d *Decoder) fileToNode(f *ast.File) ast.Node {
+ for _, doc := range f.Docs {
+ if v := d.nodeToValue(doc.Body); v != nil {
+ return doc.Body
+ }
+ }
+ return nil
+}
+
+func (d *Decoder) convertValue(v reflect.Value, typ reflect.Type) (reflect.Value, error) {
+ if typ.Kind() != reflect.String {
+ if !v.Type().ConvertibleTo(typ) {
+ return reflect.Zero(typ), errTypeMismatch(typ, v.Type())
+ }
+ return v.Convert(typ), nil
+ }
+ // cast value to string
+ switch v.Type().Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return reflect.ValueOf(fmt.Sprint(v.Int())), nil
+ case reflect.Float32, reflect.Float64:
+ return reflect.ValueOf(fmt.Sprint(v.Float())), nil
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return reflect.ValueOf(fmt.Sprint(v.Uint())), nil
+ case reflect.Bool:
+ return reflect.ValueOf(fmt.Sprint(v.Bool())), nil
+ }
+ if !v.Type().ConvertibleTo(typ) {
+ return reflect.Zero(typ), errTypeMismatch(typ, v.Type())
+ }
+ return v.Convert(typ), nil
+}
+
+type overflowError struct {
+ dstType reflect.Type
+ srcNum string
+}
+
+func (e *overflowError) Error() string {
+ return fmt.Sprintf("cannot unmarshal %s into Go value of type %s ( overflow )", e.srcNum, e.dstType)
+}
+
+func errOverflow(dstType reflect.Type, num string) *overflowError {
+ return &overflowError{dstType: dstType, srcNum: num}
+}
+
+type typeError struct {
+ dstType reflect.Type
+ srcType reflect.Type
+ structFieldName *string
+}
+
+func (e *typeError) Error() string {
+ if e.structFieldName != nil {
+ return fmt.Sprintf("cannot unmarshal %s into Go struct field %s of type %s", e.srcType, *e.structFieldName, e.dstType)
+ }
+ return fmt.Sprintf("cannot unmarshal %s into Go value of type %s", e.srcType, e.dstType)
+}
+
+func errTypeMismatch(dstType, srcType reflect.Type) *typeError {
+ return &typeError{dstType: dstType, srcType: srcType}
+}
+
+type unknownFieldError struct {
+ err error
+}
+
+func (e *unknownFieldError) Error() string {
+ return e.err.Error()
+}
+
+func errUnknownField(msg string, tk *token.Token) *unknownFieldError {
+ return &unknownFieldError{err: errors.ErrSyntax(msg, tk)}
+}
+
+func errUnexpectedNodeType(actual, expected ast.NodeType, tk *token.Token) error {
+ return errors.ErrSyntax(fmt.Sprintf("%s was used where %s is expected", actual.YAMLName(), expected.YAMLName()), tk)
+}
+
+type duplicateKeyError struct {
+ err error
+}
+
+func (e *duplicateKeyError) Error() string {
+ return e.err.Error()
+}
+
+func errDuplicateKey(msg string, tk *token.Token) *duplicateKeyError {
+ return &duplicateKeyError{err: errors.ErrSyntax(msg, tk)}
+}
+
+func (d *Decoder) deleteStructKeys(structType reflect.Type, unknownFields map[string]ast.Node) error {
+ if structType.Kind() == reflect.Ptr {
+ structType = structType.Elem()
+ }
+ structFieldMap, err := structFieldMap(structType)
+ if err != nil {
+ return errors.Wrapf(err, "failed to create struct field map")
+ }
+
+ for j := 0; j < structType.NumField(); j++ {
+ field := structType.Field(j)
+ if isIgnoredStructField(field) {
+ continue
+ }
+
+ structField, exists := structFieldMap[field.Name]
+ if !exists {
+ continue
+ }
+
+ if structField.IsInline {
+ d.deleteStructKeys(field.Type, unknownFields)
+ } else {
+ delete(unknownFields, structField.RenderName)
+ }
+ }
+ return nil
+}
+
+func (d *Decoder) lastNode(node ast.Node) ast.Node {
+ switch n := node.(type) {
+ case *ast.MappingNode:
+ if len(n.Values) > 0 {
+ return d.lastNode(n.Values[len(n.Values)-1])
+ }
+ case *ast.MappingValueNode:
+ return d.lastNode(n.Value)
+ case *ast.SequenceNode:
+ if len(n.Values) > 0 {
+ return d.lastNode(n.Values[len(n.Values)-1])
+ }
+ }
+ return node
+}
+
+func (d *Decoder) unmarshalableDocument(node ast.Node) []byte {
+ node = d.resolveAlias(node)
+ doc := node.String()
+ last := d.lastNode(node)
+ if last != nil && last.Type() == ast.LiteralType {
+ doc += "\n"
+ }
+ return []byte(doc)
+}
+
+func (d *Decoder) unmarshalableText(node ast.Node) ([]byte, bool) {
+ node = d.resolveAlias(node)
+ if node.Type() == ast.AnchorType {
+ node = node.(*ast.AnchorNode).Value
+ }
+ switch n := node.(type) {
+ case *ast.StringNode:
+ return []byte(n.Value), true
+ case *ast.LiteralNode:
+ return []byte(n.Value.GetToken().Value), true
+ default:
+ scalar, ok := n.(ast.ScalarNode)
+ if ok {
+ return []byte(fmt.Sprint(scalar.GetValue())), true
+ }
+ }
+ return nil, false
+}
+
+type jsonUnmarshaler interface {
+ UnmarshalJSON([]byte) error
+}
+
+func (d *Decoder) canDecodeByUnmarshaler(dst reflect.Value) bool {
+ iface := dst.Addr().Interface()
+ switch iface.(type) {
+ case BytesUnmarshalerContext:
+ return true
+ case BytesUnmarshaler:
+ return true
+ case InterfaceUnmarshalerContext:
+ return true
+ case InterfaceUnmarshaler:
+ return true
+ case *time.Time:
+ return true
+ case *time.Duration:
+ return true
+ case encoding.TextUnmarshaler:
+ return true
+ case jsonUnmarshaler:
+ return d.useJSONUnmarshaler
+ }
+ return false
+}
+
+func (d *Decoder) decodeByUnmarshaler(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ iface := dst.Addr().Interface()
+
+ if unmarshaler, ok := iface.(BytesUnmarshalerContext); ok {
+ if err := unmarshaler.UnmarshalYAML(ctx, d.unmarshalableDocument(src)); err != nil {
+ return errors.Wrapf(err, "failed to UnmarshalYAML")
+ }
+ return nil
+ }
+
+ if unmarshaler, ok := iface.(BytesUnmarshaler); ok {
+ if err := unmarshaler.UnmarshalYAML(d.unmarshalableDocument(src)); err != nil {
+ return errors.Wrapf(err, "failed to UnmarshalYAML")
+ }
+ return nil
+ }
+
+ if unmarshaler, ok := iface.(InterfaceUnmarshalerContext); ok {
+ if err := unmarshaler.UnmarshalYAML(ctx, func(v interface{}) error {
+ rv := reflect.ValueOf(v)
+ if rv.Type().Kind() != reflect.Ptr {
+ return errors.ErrDecodeRequiredPointerType
+ }
+ if err := d.decodeValue(ctx, rv.Elem(), src); err != nil {
+ return errors.Wrapf(err, "failed to decode value")
+ }
+ return nil
+ }); err != nil {
+ return errors.Wrapf(err, "failed to UnmarshalYAML")
+ }
+ return nil
+ }
+
+ if unmarshaler, ok := iface.(InterfaceUnmarshaler); ok {
+ if err := unmarshaler.UnmarshalYAML(func(v interface{}) error {
+ rv := reflect.ValueOf(v)
+ if rv.Type().Kind() != reflect.Ptr {
+ return errors.ErrDecodeRequiredPointerType
+ }
+ if err := d.decodeValue(ctx, rv.Elem(), src); err != nil {
+ return errors.Wrapf(err, "failed to decode value")
+ }
+ return nil
+ }); err != nil {
+ return errors.Wrapf(err, "failed to UnmarshalYAML")
+ }
+ return nil
+ }
+
+ if _, ok := iface.(*time.Time); ok {
+ return d.decodeTime(ctx, dst, src)
+ }
+
+ if _, ok := iface.(*time.Duration); ok {
+ return d.decodeDuration(ctx, dst, src)
+ }
+
+ if unmarshaler, isText := iface.(encoding.TextUnmarshaler); isText {
+ b, ok := d.unmarshalableText(src)
+ if ok {
+ if err := unmarshaler.UnmarshalText(b); err != nil {
+ return errors.Wrapf(err, "failed to UnmarshalText")
+ }
+ return nil
+ }
+ }
+
+ if d.useJSONUnmarshaler {
+ if unmarshaler, ok := iface.(jsonUnmarshaler); ok {
+ jsonBytes, err := YAMLToJSON(d.unmarshalableDocument(src))
+ if err != nil {
+ return errors.Wrapf(err, "failed to convert yaml to json")
+ }
+ jsonBytes = bytes.TrimRight(jsonBytes, "\n")
+ if err := unmarshaler.UnmarshalJSON(jsonBytes); err != nil {
+ return errors.Wrapf(err, "failed to UnmarshalJSON")
+ }
+ return nil
+ }
+ }
+
+ return xerrors.Errorf("does not implemented Unmarshaler")
+}
+
+var (
+ astNodeType = reflect.TypeOf((*ast.Node)(nil)).Elem()
+)
+
+func (d *Decoder) decodeValue(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ if src.Type() == ast.AnchorType {
+ anchorName := src.(*ast.AnchorNode).Name.GetToken().Value
+ if _, exists := d.anchorValueMap[anchorName]; !exists {
+ d.anchorValueMap[anchorName] = dst
+ }
+ }
+ if d.canDecodeByUnmarshaler(dst) {
+ if err := d.decodeByUnmarshaler(ctx, dst, src); err != nil {
+ return errors.Wrapf(err, "failed to decode by unmarshaler")
+ }
+ return nil
+ }
+ valueType := dst.Type()
+ switch valueType.Kind() {
+ case reflect.Ptr:
+ if dst.IsNil() {
+ return nil
+ }
+ if src.Type() == ast.NullType {
+ // set nil value to pointer
+ dst.Set(reflect.Zero(valueType))
+ return nil
+ }
+ v := d.createDecodableValue(dst.Type())
+ if err := d.decodeValue(ctx, v, src); err != nil {
+ return errors.Wrapf(err, "failed to decode ptr value")
+ }
+ dst.Set(d.castToAssignableValue(v, dst.Type()))
+ case reflect.Interface:
+ if dst.Type() == astNodeType {
+ dst.Set(reflect.ValueOf(src))
+ return nil
+ }
+ v := reflect.ValueOf(d.nodeToValue(src))
+ if v.IsValid() {
+ dst.Set(v)
+ }
+ case reflect.Map:
+ return d.decodeMap(ctx, dst, src)
+ case reflect.Array:
+ return d.decodeArray(ctx, dst, src)
+ case reflect.Slice:
+ if mapSlice, ok := dst.Addr().Interface().(*MapSlice); ok {
+ return d.decodeMapSlice(ctx, mapSlice, src)
+ }
+ return d.decodeSlice(ctx, dst, src)
+ case reflect.Struct:
+ if mapItem, ok := dst.Addr().Interface().(*MapItem); ok {
+ return d.decodeMapItem(ctx, mapItem, src)
+ }
+ return d.decodeStruct(ctx, dst, src)
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ v := d.nodeToValue(src)
+ switch vv := v.(type) {
+ case int64:
+ if !dst.OverflowInt(vv) {
+ dst.SetInt(vv)
+ return nil
+ }
+ case uint64:
+ if vv <= math.MaxInt64 && !dst.OverflowInt(int64(vv)) {
+ dst.SetInt(int64(vv))
+ return nil
+ }
+ case float64:
+ if vv <= math.MaxInt64 && !dst.OverflowInt(int64(vv)) {
+ dst.SetInt(int64(vv))
+ return nil
+ }
+ default:
+ return errTypeMismatch(valueType, reflect.TypeOf(v))
+ }
+ return errOverflow(valueType, fmt.Sprint(v))
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ v := d.nodeToValue(src)
+ switch vv := v.(type) {
+ case int64:
+ if 0 <= vv && !dst.OverflowUint(uint64(vv)) {
+ dst.SetUint(uint64(vv))
+ return nil
+ }
+ case uint64:
+ if !dst.OverflowUint(vv) {
+ dst.SetUint(vv)
+ return nil
+ }
+ case float64:
+ if 0 <= vv && vv <= math.MaxUint64 && !dst.OverflowUint(uint64(vv)) {
+ dst.SetUint(uint64(vv))
+ return nil
+ }
+ default:
+ return errTypeMismatch(valueType, reflect.TypeOf(v))
+ }
+ return errOverflow(valueType, fmt.Sprint(v))
+ }
+ v := reflect.ValueOf(d.nodeToValue(src))
+ if v.IsValid() {
+ convertedValue, err := d.convertValue(v, dst.Type())
+ if err != nil {
+ return errors.Wrapf(err, "failed to convert value")
+ }
+ dst.Set(convertedValue)
+ }
+ return nil
+}
+
+func (d *Decoder) createDecodableValue(typ reflect.Type) reflect.Value {
+ for {
+ if typ.Kind() == reflect.Ptr {
+ typ = typ.Elem()
+ continue
+ }
+ break
+ }
+ return reflect.New(typ).Elem()
+}
+
+func (d *Decoder) castToAssignableValue(value reflect.Value, target reflect.Type) reflect.Value {
+ if target.Kind() != reflect.Ptr {
+ return value
+ }
+ maxTryCount := 5
+ tryCount := 0
+ for {
+ if tryCount > maxTryCount {
+ return value
+ }
+ if value.Type().AssignableTo(target) {
+ break
+ }
+ value = value.Addr()
+ tryCount++
+ }
+ return value
+}
+
+func (d *Decoder) createDecodedNewValue(
+ ctx context.Context, typ reflect.Type, defaultVal reflect.Value, node ast.Node,
+) (reflect.Value, error) {
+ if node.Type() == ast.AliasType {
+ aliasName := node.(*ast.AliasNode).Value.GetToken().Value
+ newValue := d.anchorValueMap[aliasName]
+ if newValue.IsValid() {
+ return newValue, nil
+ }
+ }
+ if node.Type() == ast.NullType {
+ return reflect.Zero(typ), nil
+ }
+ newValue := d.createDecodableValue(typ)
+ for defaultVal.Kind() == reflect.Ptr {
+ defaultVal = defaultVal.Elem()
+ }
+ if defaultVal.IsValid() && defaultVal.Type().AssignableTo(newValue.Type()) {
+ newValue.Set(defaultVal)
+ }
+ if err := d.decodeValue(ctx, newValue, node); err != nil {
+ return newValue, errors.Wrapf(err, "failed to decode value")
+ }
+ return newValue, nil
+}
+
+func (d *Decoder) keyToNodeMap(node ast.Node, ignoreMergeKey bool, getKeyOrValueNode func(*ast.MapNodeIter) ast.Node) (map[string]ast.Node, error) {
+ mapNode, err := d.getMapNode(node)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get map node")
+ }
+ keyMap := map[string]struct{}{}
+ keyToNodeMap := map[string]ast.Node{}
+ if mapNode == nil {
+ return keyToNodeMap, nil
+ }
+ mapIter := mapNode.MapRange()
+ for mapIter.Next() {
+ keyNode := mapIter.Key()
+ if keyNode.Type() == ast.MergeKeyType {
+ if ignoreMergeKey {
+ continue
+ }
+ mergeMap, err := d.keyToNodeMap(mapIter.Value(), ignoreMergeKey, getKeyOrValueNode)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get keyToNodeMap by MergeKey node")
+ }
+ for k, v := range mergeMap {
+ if err := d.validateDuplicateKey(keyMap, k, v); err != nil {
+ return nil, errors.Wrapf(err, "invalid struct key")
+ }
+ keyToNodeMap[k] = v
+ }
+ } else {
+ key, ok := d.nodeToValue(keyNode).(string)
+ if !ok {
+ return nil, errors.Wrapf(err, "failed to decode map key")
+ }
+ if err := d.validateDuplicateKey(keyMap, key, keyNode); err != nil {
+ return nil, errors.Wrapf(err, "invalid struct key")
+ }
+ keyToNodeMap[key] = getKeyOrValueNode(mapIter)
+ }
+ }
+ return keyToNodeMap, nil
+}
+
+func (d *Decoder) keyToKeyNodeMap(node ast.Node, ignoreMergeKey bool) (map[string]ast.Node, error) {
+ m, err := d.keyToNodeMap(node, ignoreMergeKey, func(nodeMap *ast.MapNodeIter) ast.Node { return nodeMap.Key() })
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get keyToNodeMap")
+ }
+ return m, nil
+}
+
+func (d *Decoder) keyToValueNodeMap(node ast.Node, ignoreMergeKey bool) (map[string]ast.Node, error) {
+ m, err := d.keyToNodeMap(node, ignoreMergeKey, func(nodeMap *ast.MapNodeIter) ast.Node { return nodeMap.Value() })
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get keyToNodeMap")
+ }
+ return m, nil
+}
+
+func (d *Decoder) setDefaultValueIfConflicted(v reflect.Value, fieldMap StructFieldMap) error {
+ typ := v.Type()
+ if typ.Kind() != reflect.Struct {
+ return nil
+ }
+ embeddedStructFieldMap, err := structFieldMap(typ)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get struct field map by embedded type")
+ }
+ for i := 0; i < typ.NumField(); i++ {
+ field := typ.Field(i)
+ if isIgnoredStructField(field) {
+ continue
+ }
+ structField := embeddedStructFieldMap[field.Name]
+ if !fieldMap.isIncludedRenderName(structField.RenderName) {
+ continue
+ }
+ // if declared same key name, set default value
+ fieldValue := v.Field(i)
+ if fieldValue.CanSet() {
+ fieldValue.Set(reflect.Zero(fieldValue.Type()))
+ }
+ }
+ return nil
+}
+
+// This is a subset of the formats allowed by the regular expression
+// defined at http://yaml.org/type/timestamp.html.
+var allowedTimestampFormats = []string{
+ "2006-1-2T15:4:5.999999999Z07:00", // RCF3339Nano with short date fields.
+ "2006-1-2t15:4:5.999999999Z07:00", // RFC3339Nano with short date fields and lower-case "t".
+ "2006-1-2 15:4:5.999999999", // space separated with no time zone
+ "2006-1-2", // date only
+}
+
+func (d *Decoder) castToTime(src ast.Node) (time.Time, error) {
+ if src == nil {
+ return time.Time{}, nil
+ }
+ v := d.nodeToValue(src)
+ if t, ok := v.(time.Time); ok {
+ return t, nil
+ }
+ s, ok := v.(string)
+ if !ok {
+ return time.Time{}, errTypeMismatch(reflect.TypeOf(time.Time{}), reflect.TypeOf(v))
+ }
+ for _, format := range allowedTimestampFormats {
+ t, err := time.Parse(format, s)
+ if err != nil {
+ // invalid format
+ continue
+ }
+ return t, nil
+ }
+ return time.Time{}, nil
+}
+
+func (d *Decoder) decodeTime(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ t, err := d.castToTime(src)
+ if err != nil {
+ return errors.Wrapf(err, "failed to convert to time")
+ }
+ dst.Set(reflect.ValueOf(t))
+ return nil
+}
+
+func (d *Decoder) castToDuration(src ast.Node) (time.Duration, error) {
+ if src == nil {
+ return 0, nil
+ }
+ v := d.nodeToValue(src)
+ if t, ok := v.(time.Duration); ok {
+ return t, nil
+ }
+ s, ok := v.(string)
+ if !ok {
+ return 0, errTypeMismatch(reflect.TypeOf(time.Duration(0)), reflect.TypeOf(v))
+ }
+ t, err := time.ParseDuration(s)
+ if err != nil {
+ return 0, errors.Wrapf(err, "failed to parse duration")
+ }
+ return t, nil
+}
+
+func (d *Decoder) decodeDuration(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ t, err := d.castToDuration(src)
+ if err != nil {
+ return errors.Wrapf(err, "failed to convert to duration")
+ }
+ dst.Set(reflect.ValueOf(t))
+ return nil
+}
+
+// getMergeAliasName support single alias only
+func (d *Decoder) getMergeAliasName(src ast.Node) string {
+ mapNode, err := d.getMapNode(src)
+ if err != nil {
+ return ""
+ }
+ if mapNode == nil {
+ return ""
+ }
+ mapIter := mapNode.MapRange()
+ for mapIter.Next() {
+ key := mapIter.Key()
+ value := mapIter.Value()
+ if key.Type() == ast.MergeKeyType && value.Type() == ast.AliasType {
+ return value.(*ast.AliasNode).Value.GetToken().Value
+ }
+ }
+ return ""
+}
+
+func (d *Decoder) decodeStruct(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ if src == nil {
+ return nil
+ }
+ structType := dst.Type()
+ srcValue := reflect.ValueOf(src)
+ srcType := srcValue.Type()
+ if srcType.Kind() == reflect.Ptr {
+ srcType = srcType.Elem()
+ srcValue = srcValue.Elem()
+ }
+ if structType == srcType {
+ // dst value implements ast.Node
+ dst.Set(srcValue)
+ return nil
+ }
+ structFieldMap, err := structFieldMap(structType)
+ if err != nil {
+ return errors.Wrapf(err, "failed to create struct field map")
+ }
+ ignoreMergeKey := structFieldMap.hasMergeProperty()
+ keyToNodeMap, err := d.keyToValueNodeMap(src, ignoreMergeKey)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get keyToValueNodeMap")
+ }
+ var unknownFields map[string]ast.Node
+ if d.disallowUnknownField {
+ unknownFields, err = d.keyToKeyNodeMap(src, ignoreMergeKey)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get keyToKeyNodeMap")
+ }
+ }
+
+ aliasName := d.getMergeAliasName(src)
+ var foundErr error
+
+ for i := 0; i < structType.NumField(); i++ {
+ field := structType.Field(i)
+ if isIgnoredStructField(field) {
+ continue
+ }
+ structField := structFieldMap[field.Name]
+ if structField.IsInline {
+ fieldValue := dst.FieldByName(field.Name)
+ if structField.IsAutoAlias {
+ if aliasName != "" {
+ newFieldValue := d.anchorValueMap[aliasName]
+ if newFieldValue.IsValid() {
+ fieldValue.Set(d.castToAssignableValue(newFieldValue, fieldValue.Type()))
+ }
+ }
+ continue
+ }
+ if !fieldValue.CanSet() {
+ return xerrors.Errorf("cannot set embedded type as unexported field %s.%s", field.PkgPath, field.Name)
+ }
+ if fieldValue.Type().Kind() == reflect.Ptr && src.Type() == ast.NullType {
+ // set nil value to pointer
+ fieldValue.Set(reflect.Zero(fieldValue.Type()))
+ continue
+ }
+ mapNode := ast.Mapping(nil, false)
+ for k, v := range keyToNodeMap {
+ key := &ast.StringNode{BaseNode: &ast.BaseNode{}, Value: k}
+ mapNode.Values = append(mapNode.Values, ast.MappingValue(nil, key, v))
+ }
+ newFieldValue, err := d.createDecodedNewValue(ctx, fieldValue.Type(), fieldValue, mapNode)
+ if d.disallowUnknownField {
+ if err := d.deleteStructKeys(fieldValue.Type(), unknownFields); err != nil {
+ return errors.Wrapf(err, "cannot delete struct keys")
+ }
+ }
+
+ if err != nil {
+ if foundErr != nil {
+ continue
+ }
+ var te *typeError
+ if xerrors.As(err, &te) {
+ if te.structFieldName != nil {
+ fieldName := fmt.Sprintf("%s.%s", structType.Name(), *te.structFieldName)
+ te.structFieldName = &fieldName
+ } else {
+ fieldName := fmt.Sprintf("%s.%s", structType.Name(), field.Name)
+ te.structFieldName = &fieldName
+ }
+ foundErr = te
+ continue
+ } else {
+ foundErr = err
+ }
+ continue
+ }
+ d.setDefaultValueIfConflicted(newFieldValue, structFieldMap)
+ fieldValue.Set(d.castToAssignableValue(newFieldValue, fieldValue.Type()))
+ continue
+ }
+ v, exists := keyToNodeMap[structField.RenderName]
+ if !exists {
+ continue
+ }
+ delete(unknownFields, structField.RenderName)
+ fieldValue := dst.FieldByName(field.Name)
+ if fieldValue.Type().Kind() == reflect.Ptr && src.Type() == ast.NullType {
+ // set nil value to pointer
+ fieldValue.Set(reflect.Zero(fieldValue.Type()))
+ continue
+ }
+ newFieldValue, err := d.createDecodedNewValue(ctx, fieldValue.Type(), fieldValue, v)
+ if err != nil {
+ if foundErr != nil {
+ continue
+ }
+ var te *typeError
+ if xerrors.As(err, &te) {
+ fieldName := fmt.Sprintf("%s.%s", structType.Name(), field.Name)
+ te.structFieldName = &fieldName
+ foundErr = te
+ } else {
+ foundErr = err
+ }
+ continue
+ }
+ fieldValue.Set(d.castToAssignableValue(newFieldValue, fieldValue.Type()))
+ }
+ if foundErr != nil {
+ return errors.Wrapf(foundErr, "failed to decode value")
+ }
+
+ // Ignore unknown fields when parsing an inline struct (recognized by a nil token).
+ // Unknown fields are expected (they could be fields from the parent struct).
+ if len(unknownFields) != 0 && d.disallowUnknownField && src.GetToken() != nil {
+ for key, node := range unknownFields {
+ return errUnknownField(fmt.Sprintf(`unknown field "%s"`, key), node.GetToken())
+ }
+ }
+
+ if d.validator != nil {
+ if err := d.validator.Struct(dst.Interface()); err != nil {
+ ev := reflect.ValueOf(err)
+ if ev.Type().Kind() == reflect.Slice {
+ for i := 0; i < ev.Len(); i++ {
+ fieldErr, ok := ev.Index(i).Interface().(FieldError)
+ if !ok {
+ continue
+ }
+ fieldName := fieldErr.StructField()
+ structField, exists := structFieldMap[fieldName]
+ if !exists {
+ continue
+ }
+ node, exists := keyToNodeMap[structField.RenderName]
+ if exists {
+ // TODO: to make FieldError message cutomizable
+ return errors.ErrSyntax(fmt.Sprintf("%s", err), node.GetToken())
+ } else if t := src.GetToken(); t != nil && t.Prev != nil && t.Prev.Prev != nil {
+ // A missing required field will not be in the keyToNodeMap
+ // the error needs to be associated with the parent of the source node
+ return errors.ErrSyntax(fmt.Sprintf("%s", err), t.Prev.Prev)
+ }
+ }
+ }
+ return err
+ }
+ }
+ return nil
+}
+
+func (d *Decoder) decodeArray(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ arrayNode, err := d.getArrayNode(src)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get array node")
+ }
+ if arrayNode == nil {
+ return nil
+ }
+ iter := arrayNode.ArrayRange()
+ arrayValue := reflect.New(dst.Type()).Elem()
+ arrayType := dst.Type()
+ elemType := arrayType.Elem()
+ idx := 0
+
+ var foundErr error
+ for iter.Next() {
+ v := iter.Value()
+ if elemType.Kind() == reflect.Ptr && v.Type() == ast.NullType {
+ // set nil value to pointer
+ arrayValue.Index(idx).Set(reflect.Zero(elemType))
+ } else {
+ dstValue, err := d.createDecodedNewValue(ctx, elemType, reflect.Value{}, v)
+ if err != nil {
+ if foundErr == nil {
+ foundErr = err
+ }
+ continue
+ } else {
+ arrayValue.Index(idx).Set(d.castToAssignableValue(dstValue, elemType))
+ }
+ }
+ idx++
+ }
+ dst.Set(arrayValue)
+ if foundErr != nil {
+ return errors.Wrapf(foundErr, "failed to decode value")
+ }
+ return nil
+}
+
+func (d *Decoder) decodeSlice(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ arrayNode, err := d.getArrayNode(src)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get array node")
+ }
+ if arrayNode == nil {
+ return nil
+ }
+ iter := arrayNode.ArrayRange()
+ sliceType := dst.Type()
+ sliceValue := reflect.MakeSlice(sliceType, 0, iter.Len())
+ elemType := sliceType.Elem()
+
+ var foundErr error
+ for iter.Next() {
+ v := iter.Value()
+ if elemType.Kind() == reflect.Ptr && v.Type() == ast.NullType {
+ // set nil value to pointer
+ sliceValue = reflect.Append(sliceValue, reflect.Zero(elemType))
+ continue
+ }
+ dstValue, err := d.createDecodedNewValue(ctx, elemType, reflect.Value{}, v)
+ if err != nil {
+ if foundErr == nil {
+ foundErr = err
+ }
+ continue
+ }
+ sliceValue = reflect.Append(sliceValue, d.castToAssignableValue(dstValue, elemType))
+ }
+ dst.Set(sliceValue)
+ if foundErr != nil {
+ return errors.Wrapf(foundErr, "failed to decode value")
+ }
+ return nil
+}
+
+func (d *Decoder) decodeMapItem(ctx context.Context, dst *MapItem, src ast.Node) error {
+ mapNode, err := d.getMapNode(src)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get map node")
+ }
+ if mapNode == nil {
+ return nil
+ }
+ mapIter := mapNode.MapRange()
+ if !mapIter.Next() {
+ return nil
+ }
+ key := mapIter.Key()
+ value := mapIter.Value()
+ if key.Type() == ast.MergeKeyType {
+ if err := d.decodeMapItem(ctx, dst, value); err != nil {
+ return errors.Wrapf(err, "failed to decode map with merge key")
+ }
+ return nil
+ }
+ *dst = MapItem{
+ Key: d.nodeToValue(key),
+ Value: d.nodeToValue(value),
+ }
+ return nil
+}
+
+func (d *Decoder) validateDuplicateKey(keyMap map[string]struct{}, key interface{}, keyNode ast.Node) error {
+ k, ok := key.(string)
+ if !ok {
+ return nil
+ }
+ if d.disallowDuplicateKey {
+ if _, exists := keyMap[k]; exists {
+ return errDuplicateKey(fmt.Sprintf(`duplicate key "%s"`, k), keyNode.GetToken())
+ }
+ }
+ keyMap[k] = struct{}{}
+ return nil
+}
+
+func (d *Decoder) decodeMapSlice(ctx context.Context, dst *MapSlice, src ast.Node) error {
+ mapNode, err := d.getMapNode(src)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get map node")
+ }
+ if mapNode == nil {
+ return nil
+ }
+ mapSlice := MapSlice{}
+ mapIter := mapNode.MapRange()
+ keyMap := map[string]struct{}{}
+ for mapIter.Next() {
+ key := mapIter.Key()
+ value := mapIter.Value()
+ if key.Type() == ast.MergeKeyType {
+ var m MapSlice
+ if err := d.decodeMapSlice(ctx, &m, value); err != nil {
+ return errors.Wrapf(err, "failed to decode map with merge key")
+ }
+ for _, v := range m {
+ if err := d.validateDuplicateKey(keyMap, v.Key, value); err != nil {
+ return errors.Wrapf(err, "invalid map key")
+ }
+ mapSlice = append(mapSlice, v)
+ }
+ continue
+ }
+ k := d.nodeToValue(key)
+ if err := d.validateDuplicateKey(keyMap, k, key); err != nil {
+ return errors.Wrapf(err, "invalid map key")
+ }
+ mapSlice = append(mapSlice, MapItem{
+ Key: k,
+ Value: d.nodeToValue(value),
+ })
+ }
+ *dst = mapSlice
+ return nil
+}
+
+func (d *Decoder) decodeMap(ctx context.Context, dst reflect.Value, src ast.Node) error {
+ mapNode, err := d.getMapNode(src)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get map node")
+ }
+ if mapNode == nil {
+ return nil
+ }
+ mapType := dst.Type()
+ mapValue := reflect.MakeMap(mapType)
+ keyType := mapValue.Type().Key()
+ valueType := mapValue.Type().Elem()
+ mapIter := mapNode.MapRange()
+ keyMap := map[string]struct{}{}
+ var foundErr error
+ for mapIter.Next() {
+ key := mapIter.Key()
+ value := mapIter.Value()
+ if key.Type() == ast.MergeKeyType {
+ if err := d.decodeMap(ctx, dst, value); err != nil {
+ return errors.Wrapf(err, "failed to decode map with merge key")
+ }
+ iter := dst.MapRange()
+ for iter.Next() {
+ if err := d.validateDuplicateKey(keyMap, iter.Key(), value); err != nil {
+ return errors.Wrapf(err, "invalid map key")
+ }
+ mapValue.SetMapIndex(iter.Key(), iter.Value())
+ }
+ continue
+ }
+ k := reflect.ValueOf(d.nodeToValue(key))
+ if k.IsValid() && k.Type().ConvertibleTo(keyType) {
+ k = k.Convert(keyType)
+ }
+ if k.IsValid() {
+ if err := d.validateDuplicateKey(keyMap, k.Interface(), key); err != nil {
+ return errors.Wrapf(err, "invalid map key")
+ }
+ }
+ if valueType.Kind() == reflect.Ptr && value.Type() == ast.NullType {
+ // set nil value to pointer
+ mapValue.SetMapIndex(k, reflect.Zero(valueType))
+ continue
+ }
+ dstValue, err := d.createDecodedNewValue(ctx, valueType, reflect.Value{}, value)
+ if err != nil {
+ if foundErr == nil {
+ foundErr = err
+ }
+ }
+ if !k.IsValid() {
+ // expect nil key
+ mapValue.SetMapIndex(d.createDecodableValue(keyType), d.castToAssignableValue(dstValue, valueType))
+ continue
+ }
+ mapValue.SetMapIndex(k, d.castToAssignableValue(dstValue, valueType))
+ }
+ dst.Set(mapValue)
+ if foundErr != nil {
+ return errors.Wrapf(foundErr, "failed to decode value")
+ }
+ return nil
+}
+
+func (d *Decoder) fileToReader(file string) (io.Reader, error) {
+ reader, err := os.Open(file)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to open file")
+ }
+ return reader, nil
+}
+
+func (d *Decoder) isYAMLFile(file string) bool {
+ ext := filepath.Ext(file)
+ if ext == ".yml" {
+ return true
+ }
+ if ext == ".yaml" {
+ return true
+ }
+ return false
+}
+
+func (d *Decoder) readersUnderDir(dir string) ([]io.Reader, error) {
+ pattern := fmt.Sprintf("%s/*", dir)
+ matches, err := filepath.Glob(pattern)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get files by %s", pattern)
+ }
+ readers := []io.Reader{}
+ for _, match := range matches {
+ if !d.isYAMLFile(match) {
+ continue
+ }
+ reader, err := d.fileToReader(match)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get reader")
+ }
+ readers = append(readers, reader)
+ }
+ return readers, nil
+}
+
+func (d *Decoder) readersUnderDirRecursive(dir string) ([]io.Reader, error) {
+ readers := []io.Reader{}
+ if err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
+ if !d.isYAMLFile(path) {
+ return nil
+ }
+ reader, err := d.fileToReader(path)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get reader")
+ }
+ readers = append(readers, reader)
+ return nil
+ }); err != nil {
+ return nil, errors.Wrapf(err, "interrupt walk in %s", dir)
+ }
+ return readers, nil
+}
+
+func (d *Decoder) resolveReference() error {
+ for _, opt := range d.opts {
+ if err := opt(d); err != nil {
+ return errors.Wrapf(err, "failed to exec option")
+ }
+ }
+ for _, file := range d.referenceFiles {
+ reader, err := d.fileToReader(file)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get reader")
+ }
+ d.referenceReaders = append(d.referenceReaders, reader)
+ }
+ for _, dir := range d.referenceDirs {
+ if !d.isRecursiveDir {
+ readers, err := d.readersUnderDir(dir)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get readers from under the %s", dir)
+ }
+ d.referenceReaders = append(d.referenceReaders, readers...)
+ } else {
+ readers, err := d.readersUnderDirRecursive(dir)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get readers from under the %s", dir)
+ }
+ d.referenceReaders = append(d.referenceReaders, readers...)
+ }
+ }
+ for _, reader := range d.referenceReaders {
+ bytes, err := ioutil.ReadAll(reader)
+ if err != nil {
+ return errors.Wrapf(err, "failed to read buffer")
+ }
+
+ // assign new anchor definition to anchorMap
+ if _, err := d.parse(bytes); err != nil {
+ return errors.Wrapf(err, "failed to decode")
+ }
+ }
+ d.isResolvedReference = true
+ return nil
+}
+
+func (d *Decoder) parse(bytes []byte) (*ast.File, error) {
+ var parseMode parser.Mode
+ if d.toCommentMap != nil {
+ parseMode = parser.ParseComments
+ }
+ f, err := parser.ParseBytes(bytes, parseMode)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse yaml")
+ }
+ normalizedFile := &ast.File{}
+ for _, doc := range f.Docs {
+ // try to decode ast.Node to value and map anchor value to anchorMap
+ if v := d.nodeToValue(doc.Body); v != nil {
+ normalizedFile.Docs = append(normalizedFile.Docs, doc)
+ }
+ }
+ return normalizedFile, nil
+}
+
+func (d *Decoder) isInitialized() bool {
+ return d.parsedFile != nil
+}
+
+func (d *Decoder) decodeInit() error {
+ if !d.isResolvedReference {
+ if err := d.resolveReference(); err != nil {
+ return errors.Wrapf(err, "failed to resolve reference")
+ }
+ }
+ var buf bytes.Buffer
+ if _, err := io.Copy(&buf, d.reader); err != nil {
+ return errors.Wrapf(err, "failed to copy from reader")
+ }
+ file, err := d.parse(buf.Bytes())
+ if err != nil {
+ return errors.Wrapf(err, "failed to decode")
+ }
+ d.parsedFile = file
+ return nil
+}
+
+func (d *Decoder) decode(ctx context.Context, v reflect.Value) error {
+ if len(d.parsedFile.Docs) <= d.streamIndex {
+ return io.EOF
+ }
+ body := d.parsedFile.Docs[d.streamIndex].Body
+ if body == nil {
+ return nil
+ }
+ if err := d.decodeValue(ctx, v.Elem(), body); err != nil {
+ return errors.Wrapf(err, "failed to decode value")
+ }
+ d.streamIndex++
+ return nil
+}
+
+// Decode reads the next YAML-encoded value from its input
+// and stores it in the value pointed to by v.
+//
+// See the documentation for Unmarshal for details about the
+// conversion of YAML into a Go value.
+func (d *Decoder) Decode(v interface{}) error {
+ return d.DecodeContext(context.Background(), v)
+}
+
+// DecodeContext reads the next YAML-encoded value from its input
+// and stores it in the value pointed to by v with context.Context.
+func (d *Decoder) DecodeContext(ctx context.Context, v interface{}) error {
+ rv := reflect.ValueOf(v)
+ if rv.Type().Kind() != reflect.Ptr {
+ return errors.ErrDecodeRequiredPointerType
+ }
+ if d.isInitialized() {
+ if err := d.decode(ctx, rv); err != nil {
+ if err == io.EOF {
+ return err
+ }
+ return errors.Wrapf(err, "failed to decode")
+ }
+ return nil
+ }
+ if err := d.decodeInit(); err != nil {
+ return errors.Wrapf(err, "failed to decodeInit")
+ }
+ if err := d.decode(ctx, rv); err != nil {
+ if err == io.EOF {
+ return err
+ }
+ return errors.Wrapf(err, "failed to decode")
+ }
+ return nil
+}
+
+// DecodeFromNode decodes node into the value pointed to by v.
+func (d *Decoder) DecodeFromNode(node ast.Node, v interface{}) error {
+ return d.DecodeFromNodeContext(context.Background(), node, v)
+}
+
+// DecodeFromNodeContext decodes node into the value pointed to by v with context.Context.
+func (d *Decoder) DecodeFromNodeContext(ctx context.Context, node ast.Node, v interface{}) error {
+ rv := reflect.ValueOf(v)
+ if rv.Type().Kind() != reflect.Ptr {
+ return errors.ErrDecodeRequiredPointerType
+ }
+ if !d.isInitialized() {
+ if err := d.decodeInit(); err != nil {
+ return errors.Wrapf(err, "failed to decodInit")
+ }
+ }
+ // resolve references to the anchor on the same file
+ d.nodeToValue(node)
+ if err := d.decodeValue(ctx, rv.Elem(), node); err != nil {
+ return errors.Wrapf(err, "failed to decode value")
+ }
+ return nil
+}
diff --git a/vendor/github.com/goccy/go-yaml/encode.go b/vendor/github.com/goccy/go-yaml/encode.go
new file mode 100644
index 0000000..31eaf94
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/encode.go
@@ -0,0 +1,733 @@
+package yaml
+
+import (
+ "context"
+ "encoding"
+ "fmt"
+ "io"
+ "math"
+ "reflect"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/goccy/go-yaml/ast"
+ "github.com/goccy/go-yaml/internal/errors"
+ "github.com/goccy/go-yaml/parser"
+ "github.com/goccy/go-yaml/printer"
+ "github.com/goccy/go-yaml/token"
+ "golang.org/x/xerrors"
+)
+
+const (
+ // DefaultIndentSpaces default number of space for indent
+ DefaultIndentSpaces = 2
+)
+
+// Encoder writes YAML values to an output stream.
+type Encoder struct {
+ writer io.Writer
+ opts []EncodeOption
+ indent int
+ indentSequence bool
+ singleQuote bool
+ isFlowStyle bool
+ isJSONStyle bool
+ useJSONMarshaler bool
+ anchorCallback func(*ast.AnchorNode, interface{}) error
+ anchorPtrToNameMap map[uintptr]string
+ useLiteralStyleIfMultiline bool
+ commentMap map[*Path]*Comment
+
+ line int
+ column int
+ offset int
+ indentNum int
+ indentLevel int
+}
+
+// NewEncoder returns a new encoder that writes to w.
+// The Encoder should be closed after use to flush all data to w.
+func NewEncoder(w io.Writer, opts ...EncodeOption) *Encoder {
+ return &Encoder{
+ writer: w,
+ opts: opts,
+ indent: DefaultIndentSpaces,
+ anchorPtrToNameMap: map[uintptr]string{},
+ line: 1,
+ column: 1,
+ offset: 0,
+ }
+}
+
+// Close closes the encoder by writing any remaining data.
+// It does not write a stream terminating string "...".
+func (e *Encoder) Close() error {
+ return nil
+}
+
+// Encode writes the YAML encoding of v to the stream.
+// If multiple items are encoded to the stream,
+// the second and subsequent document will be preceded with a "---" document separator,
+// but the first will not.
+//
+// See the documentation for Marshal for details about the conversion of Go values to YAML.
+func (e *Encoder) Encode(v interface{}) error {
+ return e.EncodeContext(context.Background(), v)
+}
+
+// EncodeContext writes the YAML encoding of v to the stream with context.Context.
+func (e *Encoder) EncodeContext(ctx context.Context, v interface{}) error {
+ node, err := e.EncodeToNodeContext(ctx, v)
+ if err != nil {
+ return errors.Wrapf(err, "failed to encode to node")
+ }
+ if err := e.setCommentByCommentMap(node); err != nil {
+ return errors.Wrapf(err, "failed to set comment by comment map")
+ }
+ var p printer.Printer
+ e.writer.Write(p.PrintNode(node))
+ return nil
+}
+
+// EncodeToNode convert v to ast.Node.
+func (e *Encoder) EncodeToNode(v interface{}) (ast.Node, error) {
+ return e.EncodeToNodeContext(context.Background(), v)
+}
+
+// EncodeToNodeContext convert v to ast.Node with context.Context.
+func (e *Encoder) EncodeToNodeContext(ctx context.Context, v interface{}) (ast.Node, error) {
+ for _, opt := range e.opts {
+ if err := opt(e); err != nil {
+ return nil, errors.Wrapf(err, "failed to run option for encoder")
+ }
+ }
+ node, err := e.encodeValue(ctx, reflect.ValueOf(v), 1)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode value")
+ }
+ return node, nil
+}
+
+func (e *Encoder) setCommentByCommentMap(node ast.Node) error {
+ if e.commentMap == nil {
+ return nil
+ }
+ for path, comment := range e.commentMap {
+ n, err := path.FilterNode(node)
+ if err != nil {
+ return errors.Wrapf(err, "failed to filter node")
+ }
+ comments := []*token.Token{}
+ for _, text := range comment.Texts {
+ comments = append(comments, token.New(text, text, nil))
+ }
+ commentGroup := ast.CommentGroup(comments)
+ switch comment.Position {
+ case CommentLinePosition:
+ if err := n.SetComment(commentGroup); err != nil {
+ return errors.Wrapf(err, "failed to set comment")
+ }
+ case CommentHeadPosition:
+ parent := ast.Parent(node, n)
+ if parent == nil {
+ return ErrUnsupportedHeadPositionType(node)
+ }
+ switch node := parent.(type) {
+ case *ast.MappingValueNode:
+ if err := node.SetComment(commentGroup); err != nil {
+ return errors.Wrapf(err, "failed to set comment")
+ }
+ case *ast.MappingNode:
+ if err := node.SetComment(commentGroup); err != nil {
+ return errors.Wrapf(err, "failed to set comment")
+ }
+ default:
+ return ErrUnsupportedHeadPositionType(node)
+ }
+ default:
+ return ErrUnknownCommentPositionType
+ }
+ }
+ return nil
+}
+
+func (e *Encoder) encodeDocument(doc []byte) (ast.Node, error) {
+ f, err := parser.ParseBytes(doc, 0)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse yaml")
+ }
+ for _, docNode := range f.Docs {
+ if docNode.Body != nil {
+ return docNode.Body, nil
+ }
+ }
+ return nil, nil
+}
+
+func (e *Encoder) isInvalidValue(v reflect.Value) bool {
+ if !v.IsValid() {
+ return true
+ }
+ kind := v.Type().Kind()
+ if kind == reflect.Ptr && v.IsNil() {
+ return true
+ }
+ if kind == reflect.Interface && v.IsNil() {
+ return true
+ }
+ return false
+}
+
+type jsonMarshaler interface {
+ MarshalJSON() ([]byte, error)
+}
+
+func (e *Encoder) canEncodeByMarshaler(v reflect.Value) bool {
+ if !v.CanInterface() {
+ return false
+ }
+ iface := v.Interface()
+ switch iface.(type) {
+ case BytesMarshalerContext:
+ return true
+ case BytesMarshaler:
+ return true
+ case InterfaceMarshalerContext:
+ return true
+ case InterfaceMarshaler:
+ return true
+ case time.Time:
+ return true
+ case time.Duration:
+ return true
+ case encoding.TextMarshaler:
+ return true
+ case jsonMarshaler:
+ return e.useJSONMarshaler
+ }
+ return false
+}
+
+func (e *Encoder) encodeByMarshaler(ctx context.Context, v reflect.Value, column int) (ast.Node, error) {
+ iface := v.Interface()
+
+ if marshaler, ok := iface.(BytesMarshalerContext); ok {
+ doc, err := marshaler.MarshalYAML(ctx)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to MarshalYAML")
+ }
+ node, err := e.encodeDocument(doc)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode document")
+ }
+ return node, nil
+ }
+
+ if marshaler, ok := iface.(BytesMarshaler); ok {
+ doc, err := marshaler.MarshalYAML()
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to MarshalYAML")
+ }
+ node, err := e.encodeDocument(doc)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode document")
+ }
+ return node, nil
+ }
+
+ if marshaler, ok := iface.(InterfaceMarshalerContext); ok {
+ marshalV, err := marshaler.MarshalYAML(ctx)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to MarshalYAML")
+ }
+ return e.encodeValue(ctx, reflect.ValueOf(marshalV), column)
+ }
+
+ if marshaler, ok := iface.(InterfaceMarshaler); ok {
+ marshalV, err := marshaler.MarshalYAML()
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to MarshalYAML")
+ }
+ return e.encodeValue(ctx, reflect.ValueOf(marshalV), column)
+ }
+
+ if t, ok := iface.(time.Time); ok {
+ return e.encodeTime(t, column), nil
+ }
+
+ if t, ok := iface.(time.Duration); ok {
+ return e.encodeDuration(t, column), nil
+ }
+
+ if marshaler, ok := iface.(encoding.TextMarshaler); ok {
+ doc, err := marshaler.MarshalText()
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to MarshalText")
+ }
+ node, err := e.encodeDocument(doc)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode document")
+ }
+ return node, nil
+ }
+
+ if e.useJSONMarshaler {
+ if marshaler, ok := iface.(jsonMarshaler); ok {
+ jsonBytes, err := marshaler.MarshalJSON()
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to MarshalJSON")
+ }
+ doc, err := JSONToYAML(jsonBytes)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to convert json to yaml")
+ }
+ node, err := e.encodeDocument(doc)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode document")
+ }
+ return node, nil
+ }
+ }
+
+ return nil, xerrors.Errorf("does not implemented Marshaler")
+}
+
+func (e *Encoder) encodeValue(ctx context.Context, v reflect.Value, column int) (ast.Node, error) {
+ if e.isInvalidValue(v) {
+ return e.encodeNil(), nil
+ }
+ if e.canEncodeByMarshaler(v) {
+ node, err := e.encodeByMarshaler(ctx, v, column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode by marshaler")
+ }
+ return node, nil
+ }
+ switch v.Type().Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return e.encodeInt(v.Int()), nil
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ return e.encodeUint(v.Uint()), nil
+ case reflect.Float32:
+ return e.encodeFloat(v.Float(), 32), nil
+ case reflect.Float64:
+ return e.encodeFloat(v.Float(), 64), nil
+ case reflect.Ptr:
+ anchorName := e.anchorPtrToNameMap[v.Pointer()]
+ if anchorName != "" {
+ aliasName := anchorName
+ alias := ast.Alias(token.New("*", "*", e.pos(column)))
+ alias.Value = ast.String(token.New(aliasName, aliasName, e.pos(column)))
+ return alias, nil
+ }
+ return e.encodeValue(ctx, v.Elem(), column)
+ case reflect.Interface:
+ return e.encodeValue(ctx, v.Elem(), column)
+ case reflect.String:
+ return e.encodeString(v.String(), column), nil
+ case reflect.Bool:
+ return e.encodeBool(v.Bool()), nil
+ case reflect.Slice:
+ if mapSlice, ok := v.Interface().(MapSlice); ok {
+ return e.encodeMapSlice(ctx, mapSlice, column)
+ }
+ return e.encodeSlice(ctx, v)
+ case reflect.Array:
+ return e.encodeArray(ctx, v)
+ case reflect.Struct:
+ if v.CanInterface() {
+ if mapItem, ok := v.Interface().(MapItem); ok {
+ return e.encodeMapItem(ctx, mapItem, column)
+ }
+ if t, ok := v.Interface().(time.Time); ok {
+ return e.encodeTime(t, column), nil
+ }
+ }
+ return e.encodeStruct(ctx, v, column)
+ case reflect.Map:
+ return e.encodeMap(ctx, v, column), nil
+ default:
+ return nil, xerrors.Errorf("unknown value type %s", v.Type().String())
+ }
+ return nil, nil
+}
+
+func (e *Encoder) pos(column int) *token.Position {
+ return &token.Position{
+ Line: e.line,
+ Column: column,
+ Offset: e.offset,
+ IndentNum: e.indentNum,
+ IndentLevel: e.indentLevel,
+ }
+}
+
+func (e *Encoder) encodeNil() ast.Node {
+ value := "null"
+ return ast.Null(token.New(value, value, e.pos(e.column)))
+}
+
+func (e *Encoder) encodeInt(v int64) ast.Node {
+ value := fmt.Sprint(v)
+ return ast.Integer(token.New(value, value, e.pos(e.column)))
+}
+
+func (e *Encoder) encodeUint(v uint64) ast.Node {
+ value := fmt.Sprint(v)
+ return ast.Integer(token.New(value, value, e.pos(e.column)))
+}
+
+func (e *Encoder) encodeFloat(v float64, bitSize int) ast.Node {
+ if v == math.Inf(0) {
+ value := ".inf"
+ return ast.Infinity(token.New(value, value, e.pos(e.column)))
+ } else if v == math.Inf(-1) {
+ value := "-.inf"
+ return ast.Infinity(token.New(value, value, e.pos(e.column)))
+ } else if math.IsNaN(v) {
+ value := ".nan"
+ return ast.Nan(token.New(value, value, e.pos(e.column)))
+ }
+ value := strconv.FormatFloat(v, 'g', -1, bitSize)
+ if !strings.Contains(value, ".") && !strings.Contains(value, "e") {
+ // append x.0 suffix to keep float value context
+ value = fmt.Sprintf("%s.0", value)
+ }
+ return ast.Float(token.New(value, value, e.pos(e.column)))
+}
+
+func (e *Encoder) isNeedQuoted(v string) bool {
+ if e.isJSONStyle {
+ return true
+ }
+ if e.useLiteralStyleIfMultiline && strings.ContainsAny(v, "\n\r") {
+ return false
+ }
+ if token.IsNeedQuoted(v) {
+ return true
+ }
+ return false
+}
+
+func (e *Encoder) encodeString(v string, column int) ast.Node {
+ if e.isNeedQuoted(v) {
+ if e.singleQuote {
+ v = quoteWith(v, '\'')
+ } else {
+ v = strconv.Quote(v)
+ }
+ }
+ return ast.String(token.New(v, v, e.pos(column)))
+}
+
+func (e *Encoder) encodeBool(v bool) ast.Node {
+ value := fmt.Sprint(v)
+ return ast.Bool(token.New(value, value, e.pos(e.column)))
+}
+
+func (e *Encoder) encodeSlice(ctx context.Context, value reflect.Value) (ast.Node, error) {
+ if e.indentSequence {
+ e.column += e.indent
+ }
+ column := e.column
+ sequence := ast.Sequence(token.New("-", "-", e.pos(column)), e.isFlowStyle)
+ for i := 0; i < value.Len(); i++ {
+ node, err := e.encodeValue(ctx, value.Index(i), column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode value for slice")
+ }
+ sequence.Values = append(sequence.Values, node)
+ }
+ if e.indentSequence {
+ e.column -= e.indent
+ }
+ return sequence, nil
+}
+
+func (e *Encoder) encodeArray(ctx context.Context, value reflect.Value) (ast.Node, error) {
+ if e.indentSequence {
+ e.column += e.indent
+ }
+ column := e.column
+ sequence := ast.Sequence(token.New("-", "-", e.pos(column)), e.isFlowStyle)
+ for i := 0; i < value.Len(); i++ {
+ node, err := e.encodeValue(ctx, value.Index(i), column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode value for array")
+ }
+ sequence.Values = append(sequence.Values, node)
+ }
+ if e.indentSequence {
+ e.column -= e.indent
+ }
+ return sequence, nil
+}
+
+func (e *Encoder) encodeMapItem(ctx context.Context, item MapItem, column int) (*ast.MappingValueNode, error) {
+ k := reflect.ValueOf(item.Key)
+ v := reflect.ValueOf(item.Value)
+ value, err := e.encodeValue(ctx, v, column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode MapItem")
+ }
+ if m, ok := value.(*ast.MappingNode); ok {
+ m.AddColumn(e.indent)
+ }
+ return ast.MappingValue(
+ token.New("", "", e.pos(column)),
+ e.encodeString(k.Interface().(string), column),
+ value,
+ ), nil
+}
+
+func (e *Encoder) encodeMapSlice(ctx context.Context, value MapSlice, column int) (ast.Node, error) {
+ node := ast.Mapping(token.New("", "", e.pos(column)), e.isFlowStyle)
+ for _, item := range value {
+ value, err := e.encodeMapItem(ctx, item, column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode MapItem for MapSlice")
+ }
+ node.Values = append(node.Values, value)
+ }
+ return node, nil
+}
+
+func (e *Encoder) encodeMap(ctx context.Context, value reflect.Value, column int) ast.Node {
+ node := ast.Mapping(token.New("", "", e.pos(column)), e.isFlowStyle)
+ keys := make([]interface{}, len(value.MapKeys()))
+ for i, k := range value.MapKeys() {
+ keys[i] = k.Interface()
+ }
+ sort.Slice(keys, func(i, j int) bool {
+ return fmt.Sprint(keys[i]) < fmt.Sprint(keys[j])
+ })
+ for _, key := range keys {
+ k := reflect.ValueOf(key)
+ v := value.MapIndex(k)
+ value, err := e.encodeValue(ctx, v, column)
+ if err != nil {
+ return nil
+ }
+ if value.Type() == ast.MappingType || value.Type() == ast.MappingValueType {
+ value.AddColumn(e.indent)
+ }
+ node.Values = append(node.Values, ast.MappingValue(
+ nil,
+ e.encodeString(fmt.Sprint(key), column),
+ value,
+ ))
+ }
+ return node
+}
+
+// IsZeroer is used to check whether an object is zero to determine
+// whether it should be omitted when marshaling with the omitempty flag.
+// One notable implementation is time.Time.
+type IsZeroer interface {
+ IsZero() bool
+}
+
+func (e *Encoder) isZeroValue(v reflect.Value) bool {
+ kind := v.Kind()
+ if z, ok := v.Interface().(IsZeroer); ok {
+ if (kind == reflect.Ptr || kind == reflect.Interface) && v.IsNil() {
+ return true
+ }
+ return z.IsZero()
+ }
+ switch kind {
+ case reflect.String:
+ return len(v.String()) == 0
+ case reflect.Interface, reflect.Ptr:
+ return v.IsNil()
+ case reflect.Slice:
+ return v.Len() == 0
+ case reflect.Map:
+ return v.Len() == 0
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return v.Int() == 0
+ case reflect.Float32, reflect.Float64:
+ return v.Float() == 0
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return v.Uint() == 0
+ case reflect.Bool:
+ return !v.Bool()
+ case reflect.Struct:
+ vt := v.Type()
+ for i := v.NumField() - 1; i >= 0; i-- {
+ if vt.Field(i).PkgPath != "" {
+ continue // private field
+ }
+ if !e.isZeroValue(v.Field(i)) {
+ return false
+ }
+ }
+ return true
+ }
+ return false
+}
+
+func (e *Encoder) encodeTime(v time.Time, column int) ast.Node {
+ value := v.Format(time.RFC3339Nano)
+ if e.isJSONStyle {
+ value = strconv.Quote(value)
+ }
+ return ast.String(token.New(value, value, e.pos(column)))
+}
+
+func (e *Encoder) encodeDuration(v time.Duration, column int) ast.Node {
+ value := v.String()
+ if e.isJSONStyle {
+ value = strconv.Quote(value)
+ }
+ return ast.String(token.New(value, value, e.pos(column)))
+}
+
+func (e *Encoder) encodeAnchor(anchorName string, value ast.Node, fieldValue reflect.Value, column int) (ast.Node, error) {
+ anchorNode := ast.Anchor(token.New("&", "&", e.pos(column)))
+ anchorNode.Name = ast.String(token.New(anchorName, anchorName, e.pos(column)))
+ anchorNode.Value = value
+ if e.anchorCallback != nil {
+ if err := e.anchorCallback(anchorNode, fieldValue.Interface()); err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal anchor")
+ }
+ if snode, ok := anchorNode.Name.(*ast.StringNode); ok {
+ anchorName = snode.Value
+ }
+ }
+ if fieldValue.Kind() == reflect.Ptr {
+ e.anchorPtrToNameMap[fieldValue.Pointer()] = anchorName
+ }
+ return anchorNode, nil
+}
+
+func (e *Encoder) encodeStruct(ctx context.Context, value reflect.Value, column int) (ast.Node, error) {
+ node := ast.Mapping(token.New("", "", e.pos(column)), e.isFlowStyle)
+ structType := value.Type()
+ structFieldMap, err := structFieldMap(structType)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to get struct field map")
+ }
+ hasInlineAnchorField := false
+ var inlineAnchorValue reflect.Value
+ for i := 0; i < value.NumField(); i++ {
+ field := structType.Field(i)
+ if isIgnoredStructField(field) {
+ continue
+ }
+ fieldValue := value.FieldByName(field.Name)
+ structField := structFieldMap[field.Name]
+ if structField.IsOmitEmpty && e.isZeroValue(fieldValue) {
+ // omit encoding
+ continue
+ }
+ value, err := e.encodeValue(ctx, fieldValue, column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode value")
+ }
+ if m, ok := value.(*ast.MappingNode); ok {
+ if !e.isFlowStyle && structField.IsFlow {
+ m.SetIsFlowStyle(true)
+ }
+ value.AddColumn(e.indent)
+ } else if s, ok := value.(*ast.SequenceNode); ok {
+ if !e.isFlowStyle && structField.IsFlow {
+ s.SetIsFlowStyle(true)
+ }
+ }
+ key := e.encodeString(structField.RenderName, column)
+ switch {
+ case structField.AnchorName != "":
+ anchorNode, err := e.encodeAnchor(structField.AnchorName, value, fieldValue, column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode anchor")
+ }
+ value = anchorNode
+ case structField.IsAutoAlias:
+ if fieldValue.Kind() != reflect.Ptr {
+ return nil, xerrors.Errorf(
+ "%s in struct is not pointer type. but required automatically alias detection",
+ structField.FieldName,
+ )
+ }
+ anchorName := e.anchorPtrToNameMap[fieldValue.Pointer()]
+ if anchorName == "" {
+ return nil, xerrors.Errorf(
+ "cannot find anchor name from pointer address for automatically alias detection",
+ )
+ }
+ aliasName := anchorName
+ alias := ast.Alias(token.New("*", "*", e.pos(column)))
+ alias.Value = ast.String(token.New(aliasName, aliasName, e.pos(column)))
+ value = alias
+ if structField.IsInline {
+ // if both used alias and inline, output `<<: *alias`
+ key = ast.MergeKey(token.New("<<", "<<", e.pos(column)))
+ }
+ case structField.AliasName != "":
+ aliasName := structField.AliasName
+ alias := ast.Alias(token.New("*", "*", e.pos(column)))
+ alias.Value = ast.String(token.New(aliasName, aliasName, e.pos(column)))
+ value = alias
+ if structField.IsInline {
+ // if both used alias and inline, output `<<: *alias`
+ key = ast.MergeKey(token.New("<<", "<<", e.pos(column)))
+ }
+ case structField.IsInline:
+ isAutoAnchor := structField.IsAutoAnchor
+ if !hasInlineAnchorField {
+ hasInlineAnchorField = isAutoAnchor
+ }
+ if isAutoAnchor {
+ inlineAnchorValue = fieldValue
+ }
+ mapNode, ok := value.(ast.MapNode)
+ if !ok {
+ return nil, xerrors.Errorf("inline value is must be map or struct type")
+ }
+ mapIter := mapNode.MapRange()
+ for mapIter.Next() {
+ key := mapIter.Key()
+ value := mapIter.Value()
+ keyName := key.GetToken().Value
+ if structFieldMap.isIncludedRenderName(keyName) {
+ // if declared same key name, skip encoding this field
+ continue
+ }
+ key.AddColumn(-e.indent)
+ value.AddColumn(-e.indent)
+ node.Values = append(node.Values, ast.MappingValue(nil, key, value))
+ }
+ continue
+ case structField.IsAutoAnchor:
+ anchorNode, err := e.encodeAnchor(structField.RenderName, value, fieldValue, column)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to encode anchor")
+ }
+ value = anchorNode
+ }
+ node.Values = append(node.Values, ast.MappingValue(nil, key, value))
+ }
+ if hasInlineAnchorField {
+ node.AddColumn(e.indent)
+ anchorName := "anchor"
+ anchorNode := ast.Anchor(token.New("&", "&", e.pos(column)))
+ anchorNode.Name = ast.String(token.New(anchorName, anchorName, e.pos(column)))
+ anchorNode.Value = node
+ if e.anchorCallback != nil {
+ if err := e.anchorCallback(anchorNode, value.Addr().Interface()); err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal anchor")
+ }
+ if snode, ok := anchorNode.Name.(*ast.StringNode); ok {
+ anchorName = snode.Value
+ }
+ }
+ if inlineAnchorValue.Kind() == reflect.Ptr {
+ e.anchorPtrToNameMap[inlineAnchorValue.Pointer()] = anchorName
+ }
+ return anchorNode, nil
+ }
+ return node, nil
+}
diff --git a/vendor/github.com/goccy/go-yaml/error.go b/vendor/github.com/goccy/go-yaml/error.go
new file mode 100644
index 0000000..028b488
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/error.go
@@ -0,0 +1,54 @@
+package yaml
+
+import (
+ "github.com/goccy/go-yaml/ast"
+ "golang.org/x/xerrors"
+)
+
+var (
+ ErrInvalidQuery = xerrors.New("invalid query")
+ ErrInvalidPath = xerrors.New("invalid path instance")
+ ErrInvalidPathString = xerrors.New("invalid path string")
+ ErrNotFoundNode = xerrors.New("node not found")
+ ErrUnknownCommentPositionType = xerrors.New("unknown comment position type")
+ ErrInvalidCommentMapValue = xerrors.New("invalid comment map value. it must be not nil value")
+)
+
+func ErrUnsupportedHeadPositionType(node ast.Node) error {
+ return xerrors.Errorf("unsupported comment head position for %s", node.Type())
+}
+
+// IsInvalidQueryError whether err is ErrInvalidQuery or not.
+func IsInvalidQueryError(err error) bool {
+ return xerrors.Is(err, ErrInvalidQuery)
+}
+
+// IsInvalidPathError whether err is ErrInvalidPath or not.
+func IsInvalidPathError(err error) bool {
+ return xerrors.Is(err, ErrInvalidPath)
+}
+
+// IsInvalidPathStringError whether err is ErrInvalidPathString or not.
+func IsInvalidPathStringError(err error) bool {
+ return xerrors.Is(err, ErrInvalidPathString)
+}
+
+// IsNotFoundNodeError whether err is ErrNotFoundNode or not.
+func IsNotFoundNodeError(err error) bool {
+ return xerrors.Is(err, ErrNotFoundNode)
+}
+
+// IsInvalidTokenTypeError whether err is ast.ErrInvalidTokenType or not.
+func IsInvalidTokenTypeError(err error) bool {
+ return xerrors.Is(err, ast.ErrInvalidTokenType)
+}
+
+// IsInvalidAnchorNameError whether err is ast.ErrInvalidAnchorName or not.
+func IsInvalidAnchorNameError(err error) bool {
+ return xerrors.Is(err, ast.ErrInvalidAnchorName)
+}
+
+// IsInvalidAliasNameError whether err is ast.ErrInvalidAliasName or not.
+func IsInvalidAliasNameError(err error) bool {
+ return xerrors.Is(err, ast.ErrInvalidAliasName)
+}
diff --git a/vendor/github.com/goccy/go-yaml/go.mod b/vendor/github.com/goccy/go-yaml/go.mod
new file mode 100644
index 0000000..4d99408
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/go.mod
@@ -0,0 +1,10 @@
+module github.com/goccy/go-yaml
+
+go 1.12
+
+require (
+ github.com/fatih/color v1.10.0
+ github.com/go-playground/validator/v10 v10.4.1
+ github.com/mattn/go-colorable v0.1.8
+ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
+)
diff --git a/vendor/github.com/goccy/go-yaml/go.sum b/vendor/github.com/goccy/go-yaml/go.sum
new file mode 100644
index 0000000..8ce2a41
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/go.sum
@@ -0,0 +1,41 @@
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
+github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
+github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
+github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
+github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
+github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
+github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
+github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
+github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
+github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
+github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
+github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
+github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
+github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/github.com/goccy/go-yaml/internal/errors/error.go b/vendor/github.com/goccy/go-yaml/internal/errors/error.go
new file mode 100644
index 0000000..c7b1103
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/internal/errors/error.go
@@ -0,0 +1,222 @@
+package errors
+
+import (
+ "bytes"
+ "fmt"
+
+ "github.com/goccy/go-yaml/printer"
+ "github.com/goccy/go-yaml/token"
+ "golang.org/x/xerrors"
+)
+
+const (
+ defaultColorize = false
+ defaultIncludeSource = true
+)
+
+var (
+ ErrDecodeRequiredPointerType = xerrors.New("required pointer type value")
+)
+
+// Wrapf wrap error for stack trace
+func Wrapf(err error, msg string, args ...interface{}) error {
+ return &wrapError{
+ baseError: &baseError{},
+ err: xerrors.Errorf(msg, args...),
+ nextErr: err,
+ frame: xerrors.Caller(1),
+ }
+}
+
+// ErrSyntax create syntax error instance with message and token
+func ErrSyntax(msg string, tk *token.Token) *syntaxError {
+ return &syntaxError{
+ baseError: &baseError{},
+ msg: msg,
+ token: tk,
+ frame: xerrors.Caller(1),
+ }
+}
+
+type baseError struct {
+ state fmt.State
+ verb rune
+}
+
+func (e *baseError) Error() string {
+ return ""
+}
+
+func (e *baseError) chainStateAndVerb(err error) {
+ wrapErr, ok := err.(*wrapError)
+ if ok {
+ wrapErr.state = e.state
+ wrapErr.verb = e.verb
+ }
+ syntaxErr, ok := err.(*syntaxError)
+ if ok {
+ syntaxErr.state = e.state
+ syntaxErr.verb = e.verb
+ }
+}
+
+type wrapError struct {
+ *baseError
+ err error
+ nextErr error
+ frame xerrors.Frame
+}
+
+type myprinter struct {
+ xerrors.Printer
+ colored bool
+ inclSource bool
+}
+
+func (e *wrapError) As(target interface{}) bool {
+ err := e.nextErr
+ for {
+ if wrapErr, ok := err.(*wrapError); ok {
+ err = wrapErr.nextErr
+ continue
+ }
+ break
+ }
+ return xerrors.As(err, target)
+}
+
+func (e *wrapError) Unwrap() error {
+ return e.nextErr
+}
+
+func (e *wrapError) PrettyPrint(p xerrors.Printer, colored, inclSource bool) error {
+ return e.FormatError(&myprinter{Printer: p, colored: colored, inclSource: inclSource})
+}
+
+func (e *wrapError) FormatError(p xerrors.Printer) error {
+ if _, ok := p.(*myprinter); !ok {
+ p = &myprinter{
+ Printer: p,
+ colored: defaultColorize,
+ inclSource: defaultIncludeSource,
+ }
+ }
+ if e.verb == 'v' && e.state.Flag('+') {
+ // print stack trace for debugging
+ p.Print(e.err, "\n")
+ e.frame.Format(p)
+ e.chainStateAndVerb(e.nextErr)
+ return e.nextErr
+ }
+ err := e.nextErr
+ for {
+ if wrapErr, ok := err.(*wrapError); ok {
+ err = wrapErr.nextErr
+ continue
+ }
+ break
+ }
+ e.chainStateAndVerb(err)
+ if fmtErr, ok := err.(xerrors.Formatter); ok {
+ fmtErr.FormatError(p)
+ } else {
+ p.Print(err)
+ }
+ return nil
+}
+
+type wrapState struct {
+ org fmt.State
+}
+
+func (s *wrapState) Write(b []byte) (n int, err error) {
+ return s.org.Write(b)
+}
+
+func (s *wrapState) Width() (wid int, ok bool) {
+ return s.org.Width()
+}
+
+func (s *wrapState) Precision() (prec int, ok bool) {
+ return s.org.Precision()
+}
+
+func (s *wrapState) Flag(c int) bool {
+ // set true to 'printDetail' forced because when p.Detail() is false, xerrors.Printer no output any text
+ if c == '#' {
+ // ignore '#' keyword because xerrors.FormatError doesn't set true to printDetail.
+ // ( see https://github.com/golang/xerrors/blob/master/adaptor.go#L39-L43 )
+ return false
+ }
+ return true
+}
+
+func (e *wrapError) Format(state fmt.State, verb rune) {
+ e.state = state
+ e.verb = verb
+ xerrors.FormatError(e, &wrapState{org: state}, verb)
+}
+
+func (e *wrapError) Error() string {
+ var buf bytes.Buffer
+ e.PrettyPrint(&Sink{&buf}, defaultColorize, defaultIncludeSource)
+ return buf.String()
+}
+
+type syntaxError struct {
+ *baseError
+ msg string
+ token *token.Token
+ frame xerrors.Frame
+}
+
+func (e *syntaxError) PrettyPrint(p xerrors.Printer, colored, inclSource bool) error {
+ return e.FormatError(&myprinter{Printer: p, colored: colored, inclSource: inclSource})
+}
+
+func (e *syntaxError) FormatError(p xerrors.Printer) error {
+ var pp printer.Printer
+
+ var colored, inclSource bool
+ if mp, ok := p.(*myprinter); ok {
+ colored = mp.colored
+ inclSource = mp.inclSource
+ }
+
+ pos := fmt.Sprintf("[%d:%d] ", e.token.Position.Line, e.token.Position.Column)
+ msg := pp.PrintErrorMessage(fmt.Sprintf("%s%s", pos, e.msg), colored)
+ if inclSource {
+ msg += "\n" + pp.PrintErrorToken(e.token, colored)
+ }
+ p.Print(msg)
+
+ if e.verb == 'v' && e.state.Flag('+') {
+ // %+v
+ // print stack trace for debugging
+ e.frame.Format(p)
+ }
+ return nil
+}
+
+type PrettyPrinter interface {
+ PrettyPrint(xerrors.Printer, bool, bool) error
+}
+type Sink struct{ *bytes.Buffer }
+
+func (es *Sink) Print(args ...interface{}) {
+ fmt.Fprint(es.Buffer, args...)
+}
+
+func (es *Sink) Printf(f string, args ...interface{}) {
+ fmt.Fprintf(es.Buffer, f, args...)
+}
+
+func (es *Sink) Detail() bool {
+ return false
+}
+
+func (e *syntaxError) Error() string {
+ var buf bytes.Buffer
+ e.PrettyPrint(&Sink{&buf}, defaultColorize, defaultIncludeSource)
+ return buf.String()
+}
diff --git a/vendor/github.com/goccy/go-yaml/lexer/lexer.go b/vendor/github.com/goccy/go-yaml/lexer/lexer.go
new file mode 100644
index 0000000..3207f4f
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/lexer/lexer.go
@@ -0,0 +1,23 @@
+package lexer
+
+import (
+ "io"
+
+ "github.com/goccy/go-yaml/scanner"
+ "github.com/goccy/go-yaml/token"
+)
+
+// Tokenize split to token instances from string
+func Tokenize(src string) token.Tokens {
+ var s scanner.Scanner
+ s.Init(src)
+ var tokens token.Tokens
+ for {
+ subTokens, err := s.Scan()
+ if err == io.EOF {
+ break
+ }
+ tokens.Add(subTokens...)
+ }
+ return tokens
+}
diff --git a/vendor/github.com/goccy/go-yaml/option.go b/vendor/github.com/goccy/go-yaml/option.go
new file mode 100644
index 0000000..a285a45
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/option.go
@@ -0,0 +1,237 @@
+package yaml
+
+import (
+ "io"
+
+ "github.com/goccy/go-yaml/ast"
+)
+
+// DecodeOption functional option type for Decoder
+type DecodeOption func(d *Decoder) error
+
+// ReferenceReaders pass to Decoder that reference to anchor defined by passed readers
+func ReferenceReaders(readers ...io.Reader) DecodeOption {
+ return func(d *Decoder) error {
+ d.referenceReaders = append(d.referenceReaders, readers...)
+ return nil
+ }
+}
+
+// ReferenceFiles pass to Decoder that reference to anchor defined by passed files
+func ReferenceFiles(files ...string) DecodeOption {
+ return func(d *Decoder) error {
+ d.referenceFiles = files
+ return nil
+ }
+}
+
+// ReferenceDirs pass to Decoder that reference to anchor defined by files under the passed dirs
+func ReferenceDirs(dirs ...string) DecodeOption {
+ return func(d *Decoder) error {
+ d.referenceDirs = dirs
+ return nil
+ }
+}
+
+// RecursiveDir search yaml file recursively from passed dirs by ReferenceDirs option
+func RecursiveDir(isRecursive bool) DecodeOption {
+ return func(d *Decoder) error {
+ d.isRecursiveDir = isRecursive
+ return nil
+ }
+}
+
+// Validator set StructValidator instance to Decoder
+func Validator(v StructValidator) DecodeOption {
+ return func(d *Decoder) error {
+ d.validator = v
+ return nil
+ }
+}
+
+// Strict enable DisallowUnknownField and DisallowDuplicateKey
+func Strict() DecodeOption {
+ return func(d *Decoder) error {
+ d.disallowUnknownField = true
+ d.disallowDuplicateKey = true
+ return nil
+ }
+}
+
+// DisallowUnknownField causes the Decoder to return an error when the destination
+// is a struct and the input contains object keys which do not match any
+// non-ignored, exported fields in the destination.
+func DisallowUnknownField() DecodeOption {
+ return func(d *Decoder) error {
+ d.disallowUnknownField = true
+ return nil
+ }
+}
+
+// DisallowDuplicateKey causes an error when mapping keys that are duplicates
+func DisallowDuplicateKey() DecodeOption {
+ return func(d *Decoder) error {
+ d.disallowDuplicateKey = true
+ return nil
+ }
+}
+
+// UseOrderedMap can be interpreted as a map,
+// and uses MapSlice ( ordered map ) aggressively if there is no type specification
+func UseOrderedMap() DecodeOption {
+ return func(d *Decoder) error {
+ d.useOrderedMap = true
+ return nil
+ }
+}
+
+// UseJSONUnmarshaler if neither `BytesUnmarshaler` nor `InterfaceUnmarshaler` is implemented
+// and `UnmashalJSON([]byte)error` is implemented, convert the argument from `YAML` to `JSON` and then call it.
+func UseJSONUnmarshaler() DecodeOption {
+ return func(d *Decoder) error {
+ d.useJSONUnmarshaler = true
+ return nil
+ }
+}
+
+// EncodeOption functional option type for Encoder
+type EncodeOption func(e *Encoder) error
+
+// Indent change indent number
+func Indent(spaces int) EncodeOption {
+ return func(e *Encoder) error {
+ e.indent = spaces
+ return nil
+ }
+}
+
+// IndentSequence causes sequence values to be indented the same value as Indent
+func IndentSequence(indent bool) EncodeOption {
+ return func(e *Encoder) error {
+ e.indentSequence = indent
+ return nil
+ }
+}
+
+// UseSingleQuote determines if single or double quotes should be preferred for strings.
+func UseSingleQuote(sq bool) EncodeOption {
+ return func(e *Encoder) error {
+ e.singleQuote = sq
+ return nil
+ }
+}
+
+// Flow encoding by flow style
+func Flow(isFlowStyle bool) EncodeOption {
+ return func(e *Encoder) error {
+ e.isFlowStyle = isFlowStyle
+ return nil
+ }
+}
+
+// UseLiteralStyleIfMultiline causes encoding multiline strings with a literal syntax,
+// no matter what characters they include
+func UseLiteralStyleIfMultiline(useLiteralStyleIfMultiline bool) EncodeOption {
+ return func(e *Encoder) error {
+ e.useLiteralStyleIfMultiline = useLiteralStyleIfMultiline
+ return nil
+ }
+}
+
+// JSON encode in JSON format
+func JSON() EncodeOption {
+ return func(e *Encoder) error {
+ e.isJSONStyle = true
+ e.isFlowStyle = true
+ return nil
+ }
+}
+
+// MarshalAnchor call back if encoder find an anchor during encoding
+func MarshalAnchor(callback func(*ast.AnchorNode, interface{}) error) EncodeOption {
+ return func(e *Encoder) error {
+ e.anchorCallback = callback
+ return nil
+ }
+}
+
+// UseJSONMarshaler if neither `BytesMarshaler` nor `InterfaceMarshaler`
+// nor `encoding.TextMarshaler` is implemented and `MarshalJSON()([]byte, error)` is implemented,
+// call `MarshalJSON` to convert the returned `JSON` to `YAML` for processing.
+func UseJSONMarshaler() EncodeOption {
+ return func(e *Encoder) error {
+ e.useJSONMarshaler = true
+ return nil
+ }
+}
+
+// CommentPosition type of the position for comment.
+type CommentPosition int
+
+const (
+ CommentLinePosition CommentPosition = iota
+ CommentHeadPosition
+)
+
+func (p CommentPosition) String() string {
+ switch p {
+ case CommentLinePosition:
+ return "Line"
+ case CommentHeadPosition:
+ return "Head"
+ default:
+ return ""
+ }
+}
+
+// LineComment create a one-line comment for CommentMap.
+func LineComment(text string) *Comment {
+ return &Comment{
+ Texts: []string{text},
+ Position: CommentLinePosition,
+ }
+}
+
+// HeadComment create a multiline comment for CommentMap.
+func HeadComment(texts ...string) *Comment {
+ return &Comment{
+ Texts: texts,
+ Position: CommentHeadPosition,
+ }
+}
+
+// Comment raw data for comment.
+type Comment struct {
+ Texts []string
+ Position CommentPosition
+}
+
+// CommentMap map of the position of the comment and the comment information.
+type CommentMap map[string]*Comment
+
+// WithComment add a comment using the location and text information given in the CommentMap.
+func WithComment(cm CommentMap) EncodeOption {
+ return func(e *Encoder) error {
+ commentMap := map[*Path]*Comment{}
+ for k, v := range cm {
+ path, err := PathString(k)
+ if err != nil {
+ return err
+ }
+ commentMap[path] = v
+ }
+ e.commentMap = commentMap
+ return nil
+ }
+}
+
+// CommentToMap apply the position and content of comments in a YAML document to a CommentMap.
+func CommentToMap(cm CommentMap) DecodeOption {
+ return func(d *Decoder) error {
+ if cm == nil {
+ return ErrInvalidCommentMapValue
+ }
+ d.toCommentMap = cm
+ return nil
+ }
+}
diff --git a/vendor/github.com/goccy/go-yaml/parser/context.go b/vendor/github.com/goccy/go-yaml/parser/context.go
new file mode 100644
index 0000000..99f18b1
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/parser/context.go
@@ -0,0 +1,199 @@
+package parser
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/goccy/go-yaml/token"
+)
+
+// context context at parsing
+type context struct {
+ parent *context
+ idx int
+ size int
+ tokens token.Tokens
+ mode Mode
+ path string
+}
+
+var pathSpecialChars = []string{
+ "$", "*", ".", "[", "]",
+}
+
+func containsPathSpecialChar(path string) bool {
+ for _, char := range pathSpecialChars {
+ if strings.Contains(path, char) {
+ return true
+ }
+ }
+ return false
+}
+
+func normalizePath(path string) string {
+ if containsPathSpecialChar(path) {
+ return fmt.Sprintf("'%s'", path)
+ }
+ return path
+}
+
+func (c *context) withChild(path string) *context {
+ ctx := c.copy()
+ path = normalizePath(path)
+ ctx.path += fmt.Sprintf(".%s", path)
+ return ctx
+}
+
+func (c *context) withIndex(idx uint) *context {
+ ctx := c.copy()
+ ctx.path += fmt.Sprintf("[%d]", idx)
+ return ctx
+}
+
+func (c *context) copy() *context {
+ return &context{
+ parent: c,
+ idx: c.idx,
+ size: c.size,
+ tokens: append(token.Tokens{}, c.tokens...),
+ mode: c.mode,
+ path: c.path,
+ }
+}
+
+func (c *context) next() bool {
+ return c.idx < c.size
+}
+
+func (c *context) previousToken() *token.Token {
+ if c.idx > 0 {
+ return c.tokens[c.idx-1]
+ }
+ return nil
+}
+
+func (c *context) insertToken(idx int, tk *token.Token) {
+ if c.parent != nil {
+ c.parent.insertToken(idx, tk)
+ }
+ if c.size < idx {
+ return
+ }
+ if c.size == idx {
+ curToken := c.tokens[c.size-1]
+ tk.Next = curToken
+ curToken.Prev = tk
+
+ c.tokens = append(c.tokens, tk)
+ c.size = len(c.tokens)
+ return
+ }
+
+ curToken := c.tokens[idx]
+ tk.Next = curToken
+ curToken.Prev = tk
+
+ c.tokens = append(c.tokens[:idx+1], c.tokens[idx:]...)
+ c.tokens[idx] = tk
+ c.size = len(c.tokens)
+}
+
+func (c *context) currentToken() *token.Token {
+ if c.idx >= c.size {
+ return nil
+ }
+ return c.tokens[c.idx]
+}
+
+func (c *context) nextToken() *token.Token {
+ if c.idx+1 >= c.size {
+ return nil
+ }
+ return c.tokens[c.idx+1]
+}
+
+func (c *context) afterNextToken() *token.Token {
+ if c.idx+2 >= c.size {
+ return nil
+ }
+ return c.tokens[c.idx+2]
+}
+
+func (c *context) nextNotCommentToken() *token.Token {
+ for i := c.idx + 1; i < c.size; i++ {
+ tk := c.tokens[i]
+ if tk.Type == token.CommentType {
+ continue
+ }
+ return tk
+ }
+ return nil
+}
+
+func (c *context) afterNextNotCommentToken() *token.Token {
+ notCommentTokenCount := 0
+ for i := c.idx + 1; i < c.size; i++ {
+ tk := c.tokens[i]
+ if tk.Type == token.CommentType {
+ continue
+ }
+ notCommentTokenCount++
+ if notCommentTokenCount == 2 {
+ return tk
+ }
+ }
+ return nil
+}
+
+func (c *context) enabledComment() bool {
+ return c.mode&ParseComments != 0
+}
+
+func (c *context) isCurrentCommentToken() bool {
+ tk := c.currentToken()
+ if tk == nil {
+ return false
+ }
+ return tk.Type == token.CommentType
+}
+
+func (c *context) progressIgnoreComment(num int) {
+ if c.parent != nil {
+ c.parent.progressIgnoreComment(num)
+ }
+ if c.size <= c.idx+num {
+ c.idx = c.size
+ } else {
+ c.idx += num
+ }
+}
+
+func (c *context) progress(num int) {
+ if c.isCurrentCommentToken() {
+ return
+ }
+ c.progressIgnoreComment(num)
+}
+
+func newContext(tokens token.Tokens, mode Mode) *context {
+ filteredTokens := []*token.Token{}
+ if mode&ParseComments != 0 {
+ filteredTokens = tokens
+ } else {
+ for _, tk := range tokens {
+ if tk.Type == token.CommentType {
+ continue
+ }
+ // keep prev/next reference between tokens containing comments
+ // https://github.com/goccy/go-yaml/issues/254
+ filteredTokens = append(filteredTokens, tk)
+ }
+ }
+ return &context{
+ idx: 0,
+ size: len(filteredTokens),
+ tokens: token.Tokens(filteredTokens),
+ mode: mode,
+ path: "$",
+ }
+}
diff --git a/vendor/github.com/goccy/go-yaml/parser/parser.go b/vendor/github.com/goccy/go-yaml/parser/parser.go
new file mode 100644
index 0000000..80c9f51
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/parser/parser.go
@@ -0,0 +1,671 @@
+package parser
+
+import (
+ "fmt"
+ "io/ioutil"
+ "strings"
+
+ "github.com/goccy/go-yaml/ast"
+ "github.com/goccy/go-yaml/internal/errors"
+ "github.com/goccy/go-yaml/lexer"
+ "github.com/goccy/go-yaml/token"
+ "golang.org/x/xerrors"
+)
+
+type parser struct{}
+
+func (p *parser) parseMapping(ctx *context) (ast.Node, error) {
+ mapTk := ctx.currentToken()
+ node := ast.Mapping(mapTk, true)
+ node.SetPath(ctx.path)
+ ctx.progress(1) // skip MappingStart token
+ for ctx.next() {
+ tk := ctx.currentToken()
+ if tk.Type == token.MappingEndType {
+ node.End = tk
+ return node, nil
+ } else if tk.Type == token.CollectEntryType {
+ ctx.progress(1)
+ continue
+ }
+
+ value, err := p.parseMappingValue(ctx)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse mapping value in mapping node")
+ }
+ mvnode, ok := value.(*ast.MappingValueNode)
+ if !ok {
+ return nil, errors.ErrSyntax("failed to parse flow mapping node", value.GetToken())
+ }
+ node.Values = append(node.Values, mvnode)
+ ctx.progress(1)
+ }
+ return nil, errors.ErrSyntax("unterminated flow mapping", node.GetToken())
+}
+
+func (p *parser) parseSequence(ctx *context) (ast.Node, error) {
+ node := ast.Sequence(ctx.currentToken(), true)
+ node.SetPath(ctx.path)
+ ctx.progress(1) // skip SequenceStart token
+ for ctx.next() {
+ tk := ctx.currentToken()
+ if tk.Type == token.SequenceEndType {
+ node.End = tk
+ break
+ } else if tk.Type == token.CollectEntryType {
+ ctx.progress(1)
+ continue
+ }
+
+ value, err := p.parseToken(ctx.withIndex(uint(len(node.Values))), tk)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse sequence value in flow sequence node")
+ }
+ node.Values = append(node.Values, value)
+ ctx.progress(1)
+ }
+ return node, nil
+}
+
+func (p *parser) parseTag(ctx *context) (ast.Node, error) {
+ tagToken := ctx.currentToken()
+ node := ast.Tag(tagToken)
+ node.SetPath(ctx.path)
+ ctx.progress(1) // skip tag token
+ var (
+ value ast.Node
+ err error
+ )
+ switch token.ReservedTagKeyword(tagToken.Value) {
+ case token.MappingTag,
+ token.OrderedMapTag:
+ value, err = p.parseMapping(ctx)
+ case token.IntegerTag,
+ token.FloatTag,
+ token.StringTag,
+ token.BinaryTag,
+ token.TimestampTag,
+ token.NullTag:
+ typ := ctx.currentToken().Type
+ if typ == token.LiteralType || typ == token.FoldedType {
+ value, err = p.parseLiteral(ctx)
+ } else {
+ value = p.parseScalarValue(ctx.currentToken())
+ }
+ case token.SequenceTag,
+ token.SetTag:
+ err = errors.ErrSyntax(fmt.Sprintf("sorry, currently not supported %s tag", tagToken.Value), tagToken)
+ default:
+ // custom tag
+ value, err = p.parseToken(ctx, ctx.currentToken())
+ }
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse tag value")
+ }
+ node.Value = value
+ return node, nil
+}
+
+func (p *parser) removeLeftSideNewLineCharacter(src string) string {
+ // CR or LF or CRLF
+ return strings.TrimLeft(strings.TrimLeft(strings.TrimLeft(src, "\r"), "\n"), "\r\n")
+}
+
+func (p *parser) existsNewLineCharacter(src string) bool {
+ if strings.Index(src, "\n") > 0 {
+ return true
+ }
+ if strings.Index(src, "\r") > 0 {
+ return true
+ }
+ return false
+}
+
+func (p *parser) validateMapKey(tk *token.Token) error {
+ if tk.Type != token.StringType {
+ return nil
+ }
+ origin := p.removeLeftSideNewLineCharacter(tk.Origin)
+ if p.existsNewLineCharacter(origin) {
+ return errors.ErrSyntax("unexpected key name", tk)
+ }
+ return nil
+}
+
+func (p *parser) createNullToken(base *token.Token) *token.Token {
+ pos := *(base.Position)
+ pos.Column++
+ return token.New("null", "null", &pos)
+}
+
+func (p *parser) parseMapValue(ctx *context, key ast.Node, colonToken *token.Token) (ast.Node, error) {
+ node, err := p.createMapValueNode(ctx, key, colonToken)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to create map value node")
+ }
+ if node != nil && node.GetPath() == "" {
+ node.SetPath(ctx.path)
+ }
+ return node, nil
+}
+
+func (p *parser) createMapValueNode(ctx *context, key ast.Node, colonToken *token.Token) (ast.Node, error) {
+ tk := ctx.currentToken()
+ if tk == nil {
+ nullToken := p.createNullToken(colonToken)
+ ctx.insertToken(ctx.idx, nullToken)
+ return ast.Null(nullToken), nil
+ }
+
+ if tk.Position.Column == key.GetToken().Position.Column && tk.Type == token.StringType {
+ // in this case,
+ // ----
+ // key:
+ // next
+ nullToken := p.createNullToken(colonToken)
+ ctx.insertToken(ctx.idx, nullToken)
+ return ast.Null(nullToken), nil
+ }
+
+ if tk.Position.Column < key.GetToken().Position.Column {
+ // in this case,
+ // ----
+ // key:
+ // next
+ nullToken := p.createNullToken(colonToken)
+ ctx.insertToken(ctx.idx, nullToken)
+ return ast.Null(nullToken), nil
+ }
+
+ value, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse mapping 'value' node")
+ }
+ return value, nil
+}
+
+func (p *parser) validateMapValue(ctx *context, key, value ast.Node) error {
+ keyColumn := key.GetToken().Position.Column
+ valueColumn := value.GetToken().Position.Column
+ if keyColumn != valueColumn {
+ return nil
+ }
+ if value.Type() != ast.StringType {
+ return nil
+ }
+ ntk := ctx.nextToken()
+ if ntk == nil || (ntk.Type != token.MappingValueType && ntk.Type != token.SequenceEntryType) {
+ return errors.ErrSyntax("could not found expected ':' token", value.GetToken())
+ }
+ return nil
+}
+
+func (p *parser) parseMappingValue(ctx *context) (ast.Node, error) {
+ key, err := p.parseMapKey(ctx)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse map key")
+ }
+ keyText := key.GetToken().Value
+ key.SetPath(ctx.withChild(keyText).path)
+ if err := p.validateMapKey(key.GetToken()); err != nil {
+ return nil, errors.Wrapf(err, "validate mapping key error")
+ }
+ ctx.progress(1) // progress to mapping value token
+ tk := ctx.currentToken() // get mapping value token
+ if tk == nil {
+ return nil, errors.ErrSyntax("unexpected map", key.GetToken())
+ }
+ ctx.progress(1) // progress to value token
+ if err := p.setSameLineCommentIfExists(ctx.withChild(keyText), key); err != nil {
+ return nil, errors.Wrapf(err, "failed to set same line comment to node")
+ }
+ if key.GetComment() != nil {
+ // if current token is comment, GetComment() is not nil.
+ // then progress to value token
+ ctx.progressIgnoreComment(1)
+ }
+
+ value, err := p.parseMapValue(ctx.withChild(keyText), key, tk)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse map value")
+ }
+ if err := p.validateMapValue(ctx, key, value); err != nil {
+ return nil, errors.Wrapf(err, "failed to validate map value")
+ }
+
+ mvnode := ast.MappingValue(tk, key, value)
+ mvnode.SetPath(ctx.withChild(keyText).path)
+ node := ast.Mapping(tk, false, mvnode)
+ node.SetPath(ctx.withChild(keyText).path)
+
+ ntk := ctx.nextNotCommentToken()
+ antk := ctx.afterNextNotCommentToken()
+ for antk != nil && antk.Type == token.MappingValueType &&
+ ntk.Position.Column == key.GetToken().Position.Column {
+ ctx.progressIgnoreComment(1)
+ value, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse mapping node")
+ }
+ switch value.Type() {
+ case ast.MappingType:
+ c := value.(*ast.MappingNode)
+ comment := c.GetComment()
+ for idx, v := range c.Values {
+ if idx == 0 && comment != nil {
+ if err := v.SetComment(comment); err != nil {
+ return nil, errors.Wrapf(err, "failed to set comment token to node")
+ }
+ }
+ node.Values = append(node.Values, v)
+ }
+ case ast.MappingValueType:
+ node.Values = append(node.Values, value.(*ast.MappingValueNode))
+ default:
+ return nil, xerrors.Errorf("failed to parse mapping value node node is %s", value.Type())
+ }
+ ntk = ctx.nextNotCommentToken()
+ antk = ctx.afterNextNotCommentToken()
+ }
+ if len(node.Values) == 1 {
+ return mvnode, nil
+ }
+ return node, nil
+}
+
+func (p *parser) parseSequenceEntry(ctx *context) (ast.Node, error) {
+ tk := ctx.currentToken()
+ sequenceNode := ast.Sequence(tk, false)
+ sequenceNode.SetPath(ctx.path)
+ curColumn := tk.Position.Column
+ for tk.Type == token.SequenceEntryType {
+ ctx.progress(1) // skip sequence token
+ tk = ctx.currentToken()
+ if tk == nil {
+ return nil, errors.ErrSyntax("empty sequence entry", ctx.previousToken())
+ }
+ var comment *ast.CommentGroupNode
+ if tk.Type == token.CommentType {
+ comment = p.parseCommentOnly(ctx)
+ tk = ctx.currentToken()
+ if tk.Type != token.SequenceEntryType {
+ break
+ }
+ ctx.progress(1) // skip sequence token
+ }
+ value, err := p.parseToken(ctx.withIndex(uint(len(sequenceNode.Values))), ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse sequence")
+ }
+ if comment != nil {
+ comment.SetPath(ctx.withIndex(uint(len(sequenceNode.Values))).path)
+ sequenceNode.ValueComments = append(sequenceNode.ValueComments, comment)
+ } else {
+ sequenceNode.ValueComments = append(sequenceNode.ValueComments, nil)
+ }
+ sequenceNode.Values = append(sequenceNode.Values, value)
+ tk = ctx.nextNotCommentToken()
+ if tk == nil {
+ break
+ }
+ if tk.Type != token.SequenceEntryType {
+ break
+ }
+ if tk.Position.Column != curColumn {
+ break
+ }
+ ctx.progressIgnoreComment(1)
+ }
+ return sequenceNode, nil
+}
+
+func (p *parser) parseAnchor(ctx *context) (ast.Node, error) {
+ tk := ctx.currentToken()
+ anchor := ast.Anchor(tk)
+ anchor.SetPath(ctx.path)
+ ntk := ctx.nextToken()
+ if ntk == nil {
+ return nil, errors.ErrSyntax("unexpected anchor. anchor name is undefined", tk)
+ }
+ ctx.progress(1) // skip anchor token
+ name, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parser anchor name node")
+ }
+ anchor.Name = name
+ ntk = ctx.nextToken()
+ if ntk == nil {
+ return nil, errors.ErrSyntax("unexpected anchor. anchor value is undefined", ctx.currentToken())
+ }
+ ctx.progress(1)
+ value, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parser anchor name node")
+ }
+ anchor.Value = value
+ return anchor, nil
+}
+
+func (p *parser) parseAlias(ctx *context) (ast.Node, error) {
+ tk := ctx.currentToken()
+ alias := ast.Alias(tk)
+ alias.SetPath(ctx.path)
+ ntk := ctx.nextToken()
+ if ntk == nil {
+ return nil, errors.ErrSyntax("unexpected alias. alias name is undefined", tk)
+ }
+ ctx.progress(1) // skip alias token
+ name, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parser alias name node")
+ }
+ alias.Value = name
+ return alias, nil
+}
+
+func (p *parser) parseMapKey(ctx *context) (ast.Node, error) {
+ tk := ctx.currentToken()
+ if value := p.parseScalarValue(tk); value != nil {
+ return value, nil
+ }
+ switch tk.Type {
+ case token.MergeKeyType:
+ return ast.MergeKey(tk), nil
+ case token.MappingKeyType:
+ return p.parseMappingKey(ctx)
+ }
+ return nil, errors.ErrSyntax("unexpected mapping key", tk)
+}
+
+func (p *parser) parseStringValue(tk *token.Token) ast.Node {
+ switch tk.Type {
+ case token.StringType,
+ token.SingleQuoteType,
+ token.DoubleQuoteType:
+ return ast.String(tk)
+ }
+ return nil
+}
+
+func (p *parser) parseScalarValueWithComment(ctx *context, tk *token.Token) (ast.Node, error) {
+ node := p.parseScalarValue(tk)
+ if node == nil {
+ return nil, nil
+ }
+ node.SetPath(ctx.path)
+ if p.isSameLineComment(ctx.nextToken(), node) {
+ ctx.progress(1)
+ if err := p.setSameLineCommentIfExists(ctx, node); err != nil {
+ return nil, errors.Wrapf(err, "failed to set same line comment to node")
+ }
+ }
+ return node, nil
+}
+
+func (p *parser) parseScalarValue(tk *token.Token) ast.Node {
+ if node := p.parseStringValue(tk); node != nil {
+ return node
+ }
+ switch tk.Type {
+ case token.NullType:
+ return ast.Null(tk)
+ case token.BoolType:
+ return ast.Bool(tk)
+ case token.IntegerType,
+ token.BinaryIntegerType,
+ token.OctetIntegerType,
+ token.HexIntegerType:
+ return ast.Integer(tk)
+ case token.FloatType:
+ return ast.Float(tk)
+ case token.InfinityType:
+ return ast.Infinity(tk)
+ case token.NanType:
+ return ast.Nan(tk)
+ }
+ return nil
+}
+
+func (p *parser) parseDirective(ctx *context) (ast.Node, error) {
+ node := ast.Directive(ctx.currentToken())
+ ctx.progress(1) // skip directive token
+ value, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse directive value")
+ }
+ node.Value = value
+ ctx.progress(1)
+ tk := ctx.currentToken()
+ if tk == nil {
+ // Since current token is nil, use the previous token to specify
+ // the syntax error location.
+ return nil, errors.ErrSyntax("unexpected directive value. document not started", ctx.previousToken())
+ }
+ if tk.Type != token.DocumentHeaderType {
+ return nil, errors.ErrSyntax("unexpected directive value. document not started", ctx.currentToken())
+ }
+ return node, nil
+}
+
+func (p *parser) parseLiteral(ctx *context) (ast.Node, error) {
+ node := ast.Literal(ctx.currentToken())
+ ctx.progress(1) // skip literal/folded token
+
+ tk := ctx.currentToken()
+ var comment *ast.CommentGroupNode
+ if tk.Type == token.CommentType {
+ comment = p.parseCommentOnly(ctx)
+ comment.SetPath(ctx.path)
+ if err := node.SetComment(comment); err != nil {
+ return nil, errors.Wrapf(err, "failed to set comment to literal")
+ }
+ tk = ctx.currentToken()
+ }
+ value, err := p.parseToken(ctx, tk)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse literal/folded value")
+ }
+ snode, ok := value.(*ast.StringNode)
+ if !ok {
+ return nil, errors.ErrSyntax("unexpected token. required string token", value.GetToken())
+ }
+ node.Value = snode
+ return node, nil
+}
+
+func (p *parser) isSameLineComment(tk *token.Token, node ast.Node) bool {
+ if tk == nil {
+ return false
+ }
+ if tk.Type != token.CommentType {
+ return false
+ }
+ return tk.Position.Line == node.GetToken().Position.Line
+}
+
+func (p *parser) setSameLineCommentIfExists(ctx *context, node ast.Node) error {
+ tk := ctx.currentToken()
+ if !p.isSameLineComment(tk, node) {
+ return nil
+ }
+ comment := ast.CommentGroup([]*token.Token{tk})
+ comment.SetPath(ctx.path)
+ if err := node.SetComment(comment); err != nil {
+ return errors.Wrapf(err, "failed to set comment token to ast.Node")
+ }
+ return nil
+}
+
+func (p *parser) parseDocument(ctx *context) (*ast.DocumentNode, error) {
+ startTk := ctx.currentToken()
+ ctx.progress(1) // skip document header token
+ body, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse document body")
+ }
+ node := ast.Document(startTk, body)
+ if ntk := ctx.nextToken(); ntk != nil && ntk.Type == token.DocumentEndType {
+ node.End = ntk
+ ctx.progress(1)
+ }
+ return node, nil
+}
+
+func (p *parser) parseCommentOnly(ctx *context) *ast.CommentGroupNode {
+ commentTokens := []*token.Token{}
+ for {
+ tk := ctx.currentToken()
+ if tk == nil {
+ break
+ }
+ if tk.Type != token.CommentType {
+ break
+ }
+ commentTokens = append(commentTokens, tk)
+ ctx.progressIgnoreComment(1) // skip comment token
+ }
+ return ast.CommentGroup(commentTokens)
+}
+
+func (p *parser) parseComment(ctx *context) (ast.Node, error) {
+ group := p.parseCommentOnly(ctx)
+ node, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse node after comment")
+ }
+ if node == nil {
+ return group, nil
+ }
+ group.SetPath(node.GetPath())
+ if err := node.SetComment(group); err != nil {
+ return nil, errors.Wrapf(err, "failed to set comment token to node")
+ }
+ return node, nil
+}
+
+func (p *parser) parseMappingKey(ctx *context) (ast.Node, error) {
+ keyTk := ctx.currentToken()
+ node := ast.MappingKey(keyTk)
+ node.SetPath(ctx.path)
+ ctx.progress(1) // skip mapping key token
+ value, err := p.parseToken(ctx.withChild(keyTk.Value), ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse map key")
+ }
+ node.Value = value
+ return node, nil
+}
+
+func (p *parser) parseToken(ctx *context, tk *token.Token) (ast.Node, error) {
+ node, err := p.createNodeFromToken(ctx, tk)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to create node from token")
+ }
+ if node != nil && node.GetPath() == "" {
+ node.SetPath(ctx.path)
+ }
+ return node, nil
+}
+
+func (p *parser) createNodeFromToken(ctx *context, tk *token.Token) (ast.Node, error) {
+ if tk == nil {
+ return nil, nil
+ }
+ if tk.NextType() == token.MappingValueType {
+ node, err := p.parseMappingValue(ctx)
+ return node, err
+ }
+ node, err := p.parseScalarValueWithComment(ctx, tk)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse scalar value")
+ }
+ if node != nil {
+ return node, nil
+ }
+ switch tk.Type {
+ case token.CommentType:
+ return p.parseComment(ctx)
+ case token.MappingKeyType:
+ return p.parseMappingKey(ctx)
+ case token.DocumentHeaderType:
+ return p.parseDocument(ctx)
+ case token.MappingStartType:
+ return p.parseMapping(ctx)
+ case token.SequenceStartType:
+ return p.parseSequence(ctx)
+ case token.SequenceEntryType:
+ return p.parseSequenceEntry(ctx)
+ case token.AnchorType:
+ return p.parseAnchor(ctx)
+ case token.AliasType:
+ return p.parseAlias(ctx)
+ case token.DirectiveType:
+ return p.parseDirective(ctx)
+ case token.TagType:
+ return p.parseTag(ctx)
+ case token.LiteralType, token.FoldedType:
+ return p.parseLiteral(ctx)
+ }
+ return nil, nil
+}
+
+func (p *parser) parse(tokens token.Tokens, mode Mode) (*ast.File, error) {
+ ctx := newContext(tokens, mode)
+ file := &ast.File{Docs: []*ast.DocumentNode{}}
+ for ctx.next() {
+ node, err := p.parseToken(ctx, ctx.currentToken())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse")
+ }
+ ctx.progressIgnoreComment(1)
+ if node == nil {
+ continue
+ }
+ if doc, ok := node.(*ast.DocumentNode); ok {
+ file.Docs = append(file.Docs, doc)
+ } else {
+ file.Docs = append(file.Docs, ast.Document(nil, node))
+ }
+ }
+ return file, nil
+}
+
+type Mode uint
+
+const (
+ ParseComments Mode = 1 << iota // parse comments and add them to AST
+)
+
+// ParseBytes parse from byte slice, and returns ast.File
+func ParseBytes(bytes []byte, mode Mode) (*ast.File, error) {
+ tokens := lexer.Tokenize(string(bytes))
+ f, err := Parse(tokens, mode)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse")
+ }
+ return f, nil
+}
+
+// Parse parse from token instances, and returns ast.File
+func Parse(tokens token.Tokens, mode Mode) (*ast.File, error) {
+ var p parser
+ f, err := p.parse(tokens, mode)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse")
+ }
+ return f, nil
+}
+
+// Parse parse from filename, and returns ast.File
+func ParseFile(filename string, mode Mode) (*ast.File, error) {
+ file, err := ioutil.ReadFile(filename)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to read file: %s", filename)
+ }
+ f, err := ParseBytes(file, mode)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse")
+ }
+ f.Name = filename
+ return f, nil
+}
diff --git a/vendor/github.com/goccy/go-yaml/path.go b/vendor/github.com/goccy/go-yaml/path.go
new file mode 100644
index 0000000..7a0c3b1
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/path.go
@@ -0,0 +1,794 @@
+package yaml
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "strconv"
+ "strings"
+
+ "github.com/goccy/go-yaml/ast"
+ "github.com/goccy/go-yaml/internal/errors"
+ "github.com/goccy/go-yaml/parser"
+ "github.com/goccy/go-yaml/printer"
+)
+
+// PathString create Path from string
+//
+// YAMLPath rule
+// $ : the root object/element
+// . : child operator
+// .. : recursive descent
+// [num] : object/element of array by number
+// [*] : all objects/elements for array.
+//
+// If you want to use reserved characters such as `.` and `*` as a key name,
+// enclose them in single quotation as follows ( $.foo.'bar.baz-*'.hoge ).
+// If you want to use a single quote with reserved characters, escape it with `\` ( $.foo.'bar.baz\'s value'.hoge ).
+func PathString(s string) (*Path, error) {
+ buf := []rune(s)
+ length := len(buf)
+ cursor := 0
+ builder := &PathBuilder{}
+ for cursor < length {
+ c := buf[cursor]
+ switch c {
+ case '$':
+ builder = builder.Root()
+ cursor++
+ case '.':
+ b, buf, c, err := parsePathDot(builder, buf, cursor)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse path of dot")
+ }
+ length = len(buf)
+ builder = b
+ cursor = c
+ case '[':
+ b, buf, c, err := parsePathIndex(builder, buf, cursor)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse path of index")
+ }
+ length = len(buf)
+ builder = b
+ cursor = c
+ default:
+ return nil, errors.Wrapf(ErrInvalidPathString, "invalid path at %d", cursor)
+ }
+ }
+ return builder.Build(), nil
+}
+
+func parsePathRecursive(b *PathBuilder, buf []rune, cursor int) (*PathBuilder, []rune, int, error) {
+ length := len(buf)
+ cursor += 2 // skip .. characters
+ start := cursor
+ for ; cursor < length; cursor++ {
+ c := buf[cursor]
+ switch c {
+ case '$':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified '$' after '..' character")
+ case '*':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified '*' after '..' character")
+ case '.', '[':
+ goto end
+ case ']':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified ']' after '..' character")
+ }
+ }
+end:
+ if start == cursor {
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "not found recursive selector")
+ }
+ return b.Recursive(string(buf[start:cursor])), buf, cursor, nil
+}
+
+func parsePathDot(b *PathBuilder, buf []rune, cursor int) (*PathBuilder, []rune, int, error) {
+ length := len(buf)
+ if cursor+1 < length && buf[cursor+1] == '.' {
+ b, buf, c, err := parsePathRecursive(b, buf, cursor)
+ if err != nil {
+ return nil, nil, 0, errors.Wrapf(err, "failed to parse path of recursive")
+ }
+ return b, buf, c, nil
+ }
+ cursor++ // skip . character
+ start := cursor
+
+ // if started single quote, looking for end single quote char
+ if cursor < length && buf[cursor] == '\'' {
+ return parseQuotedKey(b, buf, cursor)
+ }
+ for ; cursor < length; cursor++ {
+ c := buf[cursor]
+ switch c {
+ case '$':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified '$' after '.' character")
+ case '*':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified '*' after '.' character")
+ case '.', '[':
+ goto end
+ case ']':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified ']' after '.' character")
+ }
+ }
+end:
+ if start == cursor {
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "cloud not find by empty key")
+ }
+ return b.child(string(buf[start:cursor])), buf, cursor, nil
+}
+
+func parseQuotedKey(b *PathBuilder, buf []rune, cursor int) (*PathBuilder, []rune, int, error) {
+ cursor++ // skip single quote
+ start := cursor
+ length := len(buf)
+ var foundEndDelim bool
+ for ; cursor < length; cursor++ {
+ switch buf[cursor] {
+ case '\\':
+ buf = append(append([]rune{}, buf[:cursor]...), buf[cursor+1:]...)
+ length = len(buf)
+ case '\'':
+ foundEndDelim = true
+ goto end
+ }
+ }
+end:
+ if !foundEndDelim {
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "could not find end delimiter for key")
+ }
+ if start == cursor {
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "could not find by empty key")
+ }
+ selector := buf[start:cursor]
+ cursor++
+ if cursor < length {
+ switch buf[cursor] {
+ case '$':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified '$' after '.' character")
+ case '*':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified '*' after '.' character")
+ case ']':
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "specified ']' after '.' character")
+ }
+ }
+ return b.child(string(selector)), buf, cursor, nil
+}
+
+func parsePathIndex(b *PathBuilder, buf []rune, cursor int) (*PathBuilder, []rune, int, error) {
+ length := len(buf)
+ cursor++ // skip '[' character
+ if length <= cursor {
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "unexpected end of YAML Path")
+ }
+ c := buf[cursor]
+ switch c {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*':
+ start := cursor
+ cursor++
+ for ; cursor < length; cursor++ {
+ c := buf[cursor]
+ switch c {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ continue
+ }
+ break
+ }
+ if buf[cursor] != ']' {
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "invalid character %s at %d", string(buf[cursor]), cursor)
+ }
+ numOrAll := string(buf[start:cursor])
+ if numOrAll == "*" {
+ return b.IndexAll(), buf, cursor + 1, nil
+ }
+ num, err := strconv.ParseInt(numOrAll, 10, 64)
+ if err != nil {
+ return nil, nil, 0, errors.Wrapf(err, "failed to parse number")
+ }
+ return b.Index(uint(num)), buf, cursor + 1, nil
+ }
+ return nil, nil, 0, errors.Wrapf(ErrInvalidPathString, "invalid character %s at %d", c, cursor)
+}
+
+// Path represent YAMLPath ( like a JSONPath ).
+type Path struct {
+ node pathNode
+}
+
+// String path to text.
+func (p *Path) String() string {
+ return p.node.String()
+}
+
+// Read decode from r and set extracted value by YAMLPath to v.
+func (p *Path) Read(r io.Reader, v interface{}) error {
+ node, err := p.ReadNode(r)
+ if err != nil {
+ return errors.Wrapf(err, "failed to read node")
+ }
+ if err := Unmarshal([]byte(node.String()), v); err != nil {
+ return errors.Wrapf(err, "failed to unmarshal")
+ }
+ return nil
+}
+
+// ReadNode create AST from r and extract node by YAMLPath.
+func (p *Path) ReadNode(r io.Reader) (ast.Node, error) {
+ if p.node == nil {
+ return nil, ErrInvalidPath
+ }
+ var buf bytes.Buffer
+ if _, err := io.Copy(&buf, r); err != nil {
+ return nil, errors.Wrapf(err, "failed to copy from reader")
+ }
+ f, err := parser.ParseBytes(buf.Bytes(), 0)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse yaml")
+ }
+ node, err := p.FilterFile(f)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter from ast.File")
+ }
+ return node, nil
+}
+
+// Filter filter from target by YAMLPath and set it to v.
+func (p *Path) Filter(target, v interface{}) error {
+ b, err := Marshal(target)
+ if err != nil {
+ return errors.Wrapf(err, "failed to marshal target value")
+ }
+ if err := p.Read(bytes.NewBuffer(b), v); err != nil {
+ return errors.Wrapf(err, "failed to read")
+ }
+ return nil
+}
+
+// FilterFile filter from ast.File by YAMLPath.
+func (p *Path) FilterFile(f *ast.File) (ast.Node, error) {
+ for _, doc := range f.Docs {
+ node, err := p.FilterNode(doc.Body)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter node by path ( %s )", p.node)
+ }
+ if node != nil {
+ return node, nil
+ }
+ }
+ return nil, errors.Wrapf(ErrNotFoundNode, "failed to find path ( %s )", p.node)
+}
+
+// FilterNode filter from node by YAMLPath.
+func (p *Path) FilterNode(node ast.Node) (ast.Node, error) {
+ n, err := p.node.filter(node)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter node by path ( %s )", p.node)
+ }
+ return n, nil
+}
+
+// MergeFromReader merge YAML text into ast.File.
+func (p *Path) MergeFromReader(dst *ast.File, src io.Reader) error {
+ var buf bytes.Buffer
+ if _, err := io.Copy(&buf, src); err != nil {
+ return errors.Wrapf(err, "failed to copy from reader")
+ }
+ file, err := parser.ParseBytes(buf.Bytes(), 0)
+ if err != nil {
+ return errors.Wrapf(err, "failed to parse")
+ }
+ if err := p.MergeFromFile(dst, file); err != nil {
+ return errors.Wrapf(err, "failed to merge file")
+ }
+ return nil
+}
+
+// MergeFromFile merge ast.File into ast.File.
+func (p *Path) MergeFromFile(dst *ast.File, src *ast.File) error {
+ base, err := p.FilterFile(dst)
+ if err != nil {
+ return errors.Wrapf(err, "failed to filter file")
+ }
+ for _, doc := range src.Docs {
+ if err := ast.Merge(base, doc); err != nil {
+ return errors.Wrapf(err, "failed to merge")
+ }
+ }
+ return nil
+}
+
+// MergeFromNode merge ast.Node into ast.File.
+func (p *Path) MergeFromNode(dst *ast.File, src ast.Node) error {
+ base, err := p.FilterFile(dst)
+ if err != nil {
+ return errors.Wrapf(err, "failed to filter file")
+ }
+ if err := ast.Merge(base, src); err != nil {
+ return errors.Wrapf(err, "failed to merge")
+ }
+ return nil
+}
+
+// ReplaceWithReader replace ast.File with io.Reader.
+func (p *Path) ReplaceWithReader(dst *ast.File, src io.Reader) error {
+ var buf bytes.Buffer
+ if _, err := io.Copy(&buf, src); err != nil {
+ return errors.Wrapf(err, "failed to copy from reader")
+ }
+ file, err := parser.ParseBytes(buf.Bytes(), 0)
+ if err != nil {
+ return errors.Wrapf(err, "failed to parse")
+ }
+ if err := p.ReplaceWithFile(dst, file); err != nil {
+ return errors.Wrapf(err, "failed to replace file")
+ }
+ return nil
+}
+
+// ReplaceWithFile replace ast.File with ast.File.
+func (p *Path) ReplaceWithFile(dst *ast.File, src *ast.File) error {
+ for _, doc := range src.Docs {
+ if err := p.ReplaceWithNode(dst, doc); err != nil {
+ return errors.Wrapf(err, "failed to replace file by path ( %s )", p.node)
+ }
+ }
+ return nil
+}
+
+// ReplaceNode replace ast.File with ast.Node.
+func (p *Path) ReplaceWithNode(dst *ast.File, node ast.Node) error {
+ for _, doc := range dst.Docs {
+ if node.Type() == ast.DocumentType {
+ node = node.(*ast.DocumentNode).Body
+ }
+ if err := p.node.replace(doc.Body, node); err != nil {
+ return errors.Wrapf(err, "failed to replace node by path ( %s )", p.node)
+ }
+ }
+ return nil
+}
+
+// AnnotateSource add annotation to passed source ( see section 5.1 in README.md ).
+func (p *Path) AnnotateSource(source []byte, colored bool) ([]byte, error) {
+ file, err := parser.ParseBytes([]byte(source), 0)
+ if err != nil {
+ return nil, err
+ }
+ node, err := p.FilterFile(file)
+ if err != nil {
+ return nil, err
+ }
+ var pp printer.Printer
+ return []byte(pp.PrintErrorToken(node.GetToken(), colored)), nil
+}
+
+// PathBuilder represent builder for YAMLPath.
+type PathBuilder struct {
+ root *rootNode
+ node pathNode
+}
+
+// Root add '$' to current path.
+func (b *PathBuilder) Root() *PathBuilder {
+ root := newRootNode()
+ return &PathBuilder{root: root, node: root}
+}
+
+// IndexAll add '[*]' to current path.
+func (b *PathBuilder) IndexAll() *PathBuilder {
+ b.node = b.node.chain(newIndexAllNode())
+ return b
+}
+
+// Recursive add '..selector' to current path.
+func (b *PathBuilder) Recursive(selector string) *PathBuilder {
+ b.node = b.node.chain(newRecursiveNode(selector))
+ return b
+}
+
+func (b *PathBuilder) containsReservedPathCharacters(path string) bool {
+ if strings.Contains(path, ".") {
+ return true
+ }
+ if strings.Contains(path, "*") {
+ return true
+ }
+ return false
+}
+
+func (b *PathBuilder) enclosedSingleQuote(name string) bool {
+ return strings.HasPrefix(name, "'") && strings.HasSuffix(name, "'")
+}
+
+func (b *PathBuilder) normalizeSelectorName(name string) string {
+ if b.enclosedSingleQuote(name) {
+ // already escaped name
+ return name
+ }
+ if b.containsReservedPathCharacters(name) {
+ escapedName := strings.ReplaceAll(name, `'`, `\'`)
+ return "'" + escapedName + "'"
+ }
+ return name
+}
+
+func (b *PathBuilder) child(name string) *PathBuilder {
+ b.node = b.node.chain(newSelectorNode(name))
+ return b
+}
+
+// Child add '.name' to current path.
+func (b *PathBuilder) Child(name string) *PathBuilder {
+ return b.child(b.normalizeSelectorName(name))
+}
+
+// Index add '[idx]' to current path.
+func (b *PathBuilder) Index(idx uint) *PathBuilder {
+ b.node = b.node.chain(newIndexNode(idx))
+ return b
+}
+
+// Build build YAMLPath.
+func (b *PathBuilder) Build() *Path {
+ return &Path{node: b.root}
+}
+
+type pathNode interface {
+ fmt.Stringer
+ chain(pathNode) pathNode
+ filter(ast.Node) (ast.Node, error)
+ replace(ast.Node, ast.Node) error
+}
+
+type basePathNode struct {
+ child pathNode
+}
+
+func (n *basePathNode) chain(node pathNode) pathNode {
+ n.child = node
+ return node
+}
+
+type rootNode struct {
+ *basePathNode
+}
+
+func newRootNode() *rootNode {
+ return &rootNode{basePathNode: &basePathNode{}}
+}
+
+func (n *rootNode) String() string {
+ s := "$"
+ if n.child != nil {
+ s += n.child.String()
+ }
+ return s
+}
+
+func (n *rootNode) filter(node ast.Node) (ast.Node, error) {
+ if n.child == nil {
+ return nil, nil
+ }
+ filtered, err := n.child.filter(node)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ return filtered, nil
+}
+
+func (n *rootNode) replace(node ast.Node, target ast.Node) error {
+ if n.child == nil {
+ return nil
+ }
+ if err := n.child.replace(node, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ return nil
+}
+
+type selectorNode struct {
+ *basePathNode
+ selector string
+}
+
+func newSelectorNode(selector string) *selectorNode {
+ return &selectorNode{
+ basePathNode: &basePathNode{},
+ selector: selector,
+ }
+}
+
+func (n *selectorNode) filter(node ast.Node) (ast.Node, error) {
+ switch node.Type() {
+ case ast.MappingType:
+ for _, value := range node.(*ast.MappingNode).Values {
+ key := value.Key.GetToken().Value
+ if key == n.selector {
+ if n.child == nil {
+ return value.Value, nil
+ }
+ filtered, err := n.child.filter(value.Value)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ return filtered, nil
+ }
+ }
+ case ast.MappingValueType:
+ value := node.(*ast.MappingValueNode)
+ key := value.Key.GetToken().Value
+ if key == n.selector {
+ if n.child == nil {
+ return value.Value, nil
+ }
+ filtered, err := n.child.filter(value.Value)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ return filtered, nil
+ }
+ default:
+ return nil, errors.Wrapf(ErrInvalidQuery, "expected node type is map or map value. but got %s", node.Type())
+ }
+ return nil, nil
+}
+
+func (n *selectorNode) replaceMapValue(value *ast.MappingValueNode, target ast.Node) error {
+ key := value.Key.GetToken().Value
+ if key != n.selector {
+ return nil
+ }
+ if n.child == nil {
+ if err := value.Replace(target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ } else {
+ if err := n.child.replace(value.Value, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ }
+ return nil
+}
+
+func (n *selectorNode) replace(node ast.Node, target ast.Node) error {
+ switch node.Type() {
+ case ast.MappingType:
+ for _, value := range node.(*ast.MappingNode).Values {
+ if err := n.replaceMapValue(value, target); err != nil {
+ return errors.Wrapf(err, "failed to replace map value")
+ }
+ }
+ case ast.MappingValueType:
+ value := node.(*ast.MappingValueNode)
+ if err := n.replaceMapValue(value, target); err != nil {
+ return errors.Wrapf(err, "failed to replace map value")
+ }
+ default:
+ return errors.Wrapf(ErrInvalidQuery, "expected node type is map or map value. but got %s", node.Type())
+ }
+ return nil
+}
+
+func (n *selectorNode) String() string {
+ s := fmt.Sprintf(".%s", n.selector)
+ if n.child != nil {
+ s += n.child.String()
+ }
+ return s
+}
+
+type indexNode struct {
+ *basePathNode
+ selector uint
+}
+
+func newIndexNode(selector uint) *indexNode {
+ return &indexNode{
+ basePathNode: &basePathNode{},
+ selector: selector,
+ }
+}
+
+func (n *indexNode) filter(node ast.Node) (ast.Node, error) {
+ if node.Type() != ast.SequenceType {
+ return nil, errors.Wrapf(ErrInvalidQuery, "expected sequence type node. but got %s", node.Type())
+ }
+ sequence := node.(*ast.SequenceNode)
+ if n.selector >= uint(len(sequence.Values)) {
+ return nil, errors.Wrapf(ErrInvalidQuery, "expected index is %d. but got sequences has %d items", n.selector, sequence.Values)
+ }
+ value := sequence.Values[n.selector]
+ if n.child == nil {
+ return value, nil
+ }
+ filtered, err := n.child.filter(value)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ return filtered, nil
+}
+
+func (n *indexNode) replace(node ast.Node, target ast.Node) error {
+ if node.Type() != ast.SequenceType {
+ return errors.Wrapf(ErrInvalidQuery, "expected sequence type node. but got %s", node.Type())
+ }
+ sequence := node.(*ast.SequenceNode)
+ if n.selector >= uint(len(sequence.Values)) {
+ return errors.Wrapf(ErrInvalidQuery, "expected index is %d. but got sequences has %d items", n.selector, sequence.Values)
+ }
+ if n.child == nil {
+ if err := sequence.Replace(int(n.selector), target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ return nil
+ }
+ if err := n.child.replace(sequence.Values[n.selector], target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ return nil
+}
+
+func (n *indexNode) String() string {
+ s := fmt.Sprintf("[%d]", n.selector)
+ if n.child != nil {
+ s += n.child.String()
+ }
+ return s
+}
+
+type indexAllNode struct {
+ *basePathNode
+}
+
+func newIndexAllNode() *indexAllNode {
+ return &indexAllNode{
+ basePathNode: &basePathNode{},
+ }
+}
+
+func (n *indexAllNode) String() string {
+ s := "[*]"
+ if n.child != nil {
+ s += n.child.String()
+ }
+ return s
+}
+
+func (n *indexAllNode) filter(node ast.Node) (ast.Node, error) {
+ if node.Type() != ast.SequenceType {
+ return nil, errors.Wrapf(ErrInvalidQuery, "expected sequence type node. but got %s", node.Type())
+ }
+ sequence := node.(*ast.SequenceNode)
+ if n.child == nil {
+ return sequence, nil
+ }
+ out := *sequence
+ out.Values = []ast.Node{}
+ for _, value := range sequence.Values {
+ filtered, err := n.child.filter(value)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ out.Values = append(out.Values, filtered)
+ }
+ return &out, nil
+}
+
+func (n *indexAllNode) replace(node ast.Node, target ast.Node) error {
+ if node.Type() != ast.SequenceType {
+ return errors.Wrapf(ErrInvalidQuery, "expected sequence type node. but got %s", node.Type())
+ }
+ sequence := node.(*ast.SequenceNode)
+ if n.child == nil {
+ for idx := range sequence.Values {
+ if err := sequence.Replace(idx, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ }
+ return nil
+ }
+ for _, value := range sequence.Values {
+ if err := n.child.replace(value, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ }
+ return nil
+}
+
+type recursiveNode struct {
+ *basePathNode
+ selector string
+}
+
+func newRecursiveNode(selector string) *recursiveNode {
+ return &recursiveNode{
+ basePathNode: &basePathNode{},
+ selector: selector,
+ }
+}
+
+func (n *recursiveNode) String() string {
+ s := fmt.Sprintf("..%s", n.selector)
+ if n.child != nil {
+ s += n.child.String()
+ }
+ return s
+}
+
+func (n *recursiveNode) filterNode(node ast.Node) (*ast.SequenceNode, error) {
+ sequence := &ast.SequenceNode{BaseNode: &ast.BaseNode{}}
+ switch typedNode := node.(type) {
+ case *ast.MappingNode:
+ for _, value := range typedNode.Values {
+ seq, err := n.filterNode(value)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ sequence.Values = append(sequence.Values, seq.Values...)
+ }
+ case *ast.MappingValueNode:
+ key := typedNode.Key.GetToken().Value
+ if n.selector == key {
+ sequence.Values = append(sequence.Values, typedNode.Value)
+ }
+ seq, err := n.filterNode(typedNode.Value)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ sequence.Values = append(sequence.Values, seq.Values...)
+ case *ast.SequenceNode:
+ for _, value := range typedNode.Values {
+ seq, err := n.filterNode(value)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ sequence.Values = append(sequence.Values, seq.Values...)
+ }
+ }
+ return sequence, nil
+}
+
+func (n *recursiveNode) filter(node ast.Node) (ast.Node, error) {
+ sequence, err := n.filterNode(node)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to filter")
+ }
+ sequence.Start = node.GetToken()
+ return sequence, nil
+}
+
+func (n *recursiveNode) replaceNode(node ast.Node, target ast.Node) error {
+ switch typedNode := node.(type) {
+ case *ast.MappingNode:
+ for _, value := range typedNode.Values {
+ if err := n.replaceNode(value, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ }
+ case *ast.MappingValueNode:
+ key := typedNode.Key.GetToken().Value
+ if n.selector == key {
+ if err := typedNode.Replace(target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ }
+ if err := n.replaceNode(typedNode.Value, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ case *ast.SequenceNode:
+ for _, value := range typedNode.Values {
+ if err := n.replaceNode(value, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ }
+ }
+ return nil
+}
+
+func (n *recursiveNode) replace(node ast.Node, target ast.Node) error {
+ if err := n.replaceNode(node, target); err != nil {
+ return errors.Wrapf(err, "failed to replace")
+ }
+ return nil
+}
diff --git a/vendor/github.com/goccy/go-yaml/printer/printer.go b/vendor/github.com/goccy/go-yaml/printer/printer.go
new file mode 100644
index 0000000..d5e25dc
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/printer/printer.go
@@ -0,0 +1,352 @@
+package printer
+
+import (
+ "fmt"
+ "math"
+ "strings"
+
+ "github.com/fatih/color"
+ "github.com/goccy/go-yaml/ast"
+ "github.com/goccy/go-yaml/token"
+)
+
+// Property additional property set for each the token
+type Property struct {
+ Prefix string
+ Suffix string
+}
+
+// PrintFunc returns property instance
+type PrintFunc func() *Property
+
+// Printer create text from token collection or ast
+type Printer struct {
+ LineNumber bool
+ LineNumberFormat func(num int) string
+ MapKey PrintFunc
+ Anchor PrintFunc
+ Alias PrintFunc
+ Bool PrintFunc
+ String PrintFunc
+ Number PrintFunc
+}
+
+func defaultLineNumberFormat(num int) string {
+ return fmt.Sprintf("%2d | ", num)
+}
+
+func (p *Printer) property(tk *token.Token) *Property {
+ prop := &Property{}
+ switch tk.PreviousType() {
+ case token.AnchorType:
+ if p.Anchor != nil {
+ return p.Anchor()
+ }
+ return prop
+ case token.AliasType:
+ if p.Alias != nil {
+ return p.Alias()
+ }
+ return prop
+ }
+ switch tk.NextType() {
+ case token.MappingValueType:
+ if p.MapKey != nil {
+ return p.MapKey()
+ }
+ return prop
+ }
+ switch tk.Type {
+ case token.BoolType:
+ if p.Bool != nil {
+ return p.Bool()
+ }
+ return prop
+ case token.AnchorType:
+ if p.Anchor != nil {
+ return p.Anchor()
+ }
+ return prop
+ case token.AliasType:
+ if p.Anchor != nil {
+ return p.Alias()
+ }
+ return prop
+ case token.StringType, token.SingleQuoteType, token.DoubleQuoteType:
+ if p.String != nil {
+ return p.String()
+ }
+ return prop
+ case token.IntegerType, token.FloatType:
+ if p.Number != nil {
+ return p.Number()
+ }
+ return prop
+ default:
+ }
+ return prop
+}
+
+// PrintTokens create text from token collection
+func (p *Printer) PrintTokens(tokens token.Tokens) string {
+ if len(tokens) == 0 {
+ return ""
+ }
+ if p.LineNumber {
+ if p.LineNumberFormat == nil {
+ p.LineNumberFormat = defaultLineNumberFormat
+ }
+ }
+ texts := []string{}
+ lineNumber := tokens[0].Position.Line
+ for _, tk := range tokens {
+ lines := strings.Split(tk.Origin, "\n")
+ prop := p.property(tk)
+ header := ""
+ if p.LineNumber {
+ header = p.LineNumberFormat(lineNumber)
+ }
+ if len(lines) == 1 {
+ line := prop.Prefix + lines[0] + prop.Suffix
+ if len(texts) == 0 {
+ texts = append(texts, header+line)
+ lineNumber++
+ } else {
+ text := texts[len(texts)-1]
+ texts[len(texts)-1] = text + line
+ }
+ } else {
+ for idx, src := range lines {
+ if p.LineNumber {
+ header = p.LineNumberFormat(lineNumber)
+ }
+ line := prop.Prefix + src + prop.Suffix
+ if idx == 0 {
+ if len(texts) == 0 {
+ texts = append(texts, header+line)
+ lineNumber++
+ } else {
+ text := texts[len(texts)-1]
+ texts[len(texts)-1] = text + line
+ }
+ } else {
+ texts = append(texts, fmt.Sprintf("%s%s", header, line))
+ lineNumber++
+ }
+ }
+ }
+ }
+ return strings.Join(texts, "\n")
+}
+
+// PrintNode create text from ast.Node
+func (p *Printer) PrintNode(node ast.Node) []byte {
+ return []byte(fmt.Sprintf("%+v\n", node))
+}
+
+const escape = "\x1b"
+
+func format(attr color.Attribute) string {
+ return fmt.Sprintf("%s[%dm", escape, attr)
+}
+
+func (p *Printer) setDefaultColorSet() {
+ p.Bool = func() *Property {
+ return &Property{
+ Prefix: format(color.FgHiMagenta),
+ Suffix: format(color.Reset),
+ }
+ }
+ p.Number = func() *Property {
+ return &Property{
+ Prefix: format(color.FgHiMagenta),
+ Suffix: format(color.Reset),
+ }
+ }
+ p.MapKey = func() *Property {
+ return &Property{
+ Prefix: format(color.FgHiCyan),
+ Suffix: format(color.Reset),
+ }
+ }
+ p.Anchor = func() *Property {
+ return &Property{
+ Prefix: format(color.FgHiYellow),
+ Suffix: format(color.Reset),
+ }
+ }
+ p.Alias = func() *Property {
+ return &Property{
+ Prefix: format(color.FgHiYellow),
+ Suffix: format(color.Reset),
+ }
+ }
+ p.String = func() *Property {
+ return &Property{
+ Prefix: format(color.FgHiGreen),
+ Suffix: format(color.Reset),
+ }
+ }
+}
+
+func (p *Printer) PrintErrorMessage(msg string, isColored bool) string {
+ if isColored {
+ return fmt.Sprintf("%s%s%s",
+ format(color.FgHiRed),
+ msg,
+ format(color.Reset),
+ )
+ }
+ return msg
+}
+
+func (p *Printer) removeLeftSideNewLineChar(src string) string {
+ return strings.TrimLeft(strings.TrimLeft(strings.TrimLeft(src, "\r"), "\n"), "\r\n")
+}
+
+func (p *Printer) removeRightSideNewLineChar(src string) string {
+ return strings.TrimRight(strings.TrimRight(strings.TrimRight(src, "\r"), "\n"), "\r\n")
+}
+
+func (p *Printer) removeRightSideWhiteSpaceChar(src string) string {
+ return p.removeRightSideNewLineChar(strings.TrimRight(src, " "))
+}
+
+func (p *Printer) newLineCount(s string) int {
+ src := []rune(s)
+ size := len(src)
+ cnt := 0
+ for i := 0; i < size; i++ {
+ c := src[i]
+ switch c {
+ case '\r':
+ if i+1 < size && src[i+1] == '\n' {
+ i++
+ }
+ cnt++
+ case '\n':
+ cnt++
+ }
+ }
+ return cnt
+}
+
+func (p *Printer) isNewLineLastChar(s string) bool {
+ for i := len(s) - 1; i > 0; i-- {
+ c := s[i]
+ switch c {
+ case ' ':
+ continue
+ case '\n', '\r':
+ return true
+ }
+ break
+ }
+ return false
+}
+
+func (p *Printer) printBeforeTokens(tk *token.Token, minLine, extLine int) token.Tokens {
+ for {
+ if tk.Prev == nil {
+ break
+ }
+ if tk.Prev.Position.Line < minLine {
+ break
+ }
+ tk = tk.Prev
+ }
+ minTk := tk.Clone()
+ if minTk.Prev != nil {
+ // add white spaces to minTk by prev token
+ prev := minTk.Prev
+ whiteSpaceLen := len(prev.Origin) - len(strings.TrimRight(prev.Origin, " "))
+ minTk.Origin = strings.Repeat(" ", whiteSpaceLen) + minTk.Origin
+ }
+ minTk.Origin = p.removeLeftSideNewLineChar(minTk.Origin)
+ tokens := token.Tokens{minTk}
+ tk = minTk.Next
+ for tk != nil && tk.Position.Line <= extLine {
+ clonedTk := tk.Clone()
+ tokens.Add(clonedTk)
+ tk = clonedTk.Next
+ }
+ lastTk := tokens[len(tokens)-1]
+ trimmedOrigin := p.removeRightSideWhiteSpaceChar(lastTk.Origin)
+ suffix := lastTk.Origin[len(trimmedOrigin):]
+ lastTk.Origin = trimmedOrigin
+
+ if lastTk.Next != nil && len(suffix) > 1 {
+ next := lastTk.Next.Clone()
+ // add suffix to header of next token
+ if suffix[0] == '\n' || suffix[0] == '\r' {
+ suffix = suffix[1:]
+ }
+ next.Origin = suffix + next.Origin
+ lastTk.Next = next
+ }
+ return tokens
+}
+
+func (p *Printer) printAfterTokens(tk *token.Token, maxLine int) token.Tokens {
+ tokens := token.Tokens{}
+ if tk == nil {
+ return tokens
+ }
+ if tk.Position.Line > maxLine {
+ return tokens
+ }
+ minTk := tk.Clone()
+ minTk.Origin = p.removeLeftSideNewLineChar(minTk.Origin)
+ tokens.Add(minTk)
+ tk = minTk.Next
+ for tk != nil && tk.Position.Line <= maxLine {
+ clonedTk := tk.Clone()
+ tokens.Add(clonedTk)
+ tk = clonedTk.Next
+ }
+ return tokens
+}
+
+func (p *Printer) setupErrorTokenFormat(annotateLine int, isColored bool) {
+ prefix := func(annotateLine, num int) string {
+ if annotateLine == num {
+ return fmt.Sprintf("> %2d | ", num)
+ }
+ return fmt.Sprintf(" %2d | ", num)
+ }
+ p.LineNumber = true
+ p.LineNumberFormat = func(num int) string {
+ if isColored {
+ fn := color.New(color.Bold, color.FgHiWhite).SprintFunc()
+ return fn(prefix(annotateLine, num))
+ }
+ return prefix(annotateLine, num)
+ }
+ if isColored {
+ p.setDefaultColorSet()
+ }
+}
+
+func (p *Printer) PrintErrorToken(tk *token.Token, isColored bool) string {
+ errToken := tk
+ curLine := tk.Position.Line
+ curExtLine := curLine + p.newLineCount(p.removeLeftSideNewLineChar(tk.Origin))
+ if p.isNewLineLastChar(tk.Origin) {
+ // if last character ( exclude white space ) is new line character, ignore it.
+ curExtLine--
+ }
+
+ minLine := int(math.Max(float64(curLine-3), 1))
+ maxLine := curExtLine + 3
+ p.setupErrorTokenFormat(curLine, isColored)
+
+ beforeTokens := p.printBeforeTokens(tk, minLine, curExtLine)
+ lastTk := beforeTokens[len(beforeTokens)-1]
+ afterTokens := p.printAfterTokens(lastTk.Next, maxLine)
+
+ beforeSource := p.PrintTokens(beforeTokens)
+ prefixSpaceNum := len(fmt.Sprintf(" %2d | ", curLine))
+ annotateLine := strings.Repeat(" ", prefixSpaceNum+errToken.Position.Column-1) + "^"
+ afterSource := p.PrintTokens(afterTokens)
+ return fmt.Sprintf("%s\n%s\n%s", beforeSource, annotateLine, afterSource)
+}
diff --git a/vendor/github.com/goccy/go-yaml/scanner/context.go b/vendor/github.com/goccy/go-yaml/scanner/context.go
new file mode 100644
index 0000000..e629a5c
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/scanner/context.go
@@ -0,0 +1,201 @@
+package scanner
+
+import (
+ "sync"
+
+ "github.com/goccy/go-yaml/token"
+)
+
+// Context context at scanning
+type Context struct {
+ idx int
+ size int
+ notSpaceCharPos int
+ notSpaceOrgCharPos int
+ src []rune
+ buf []rune
+ obuf []rune
+ tokens token.Tokens
+ isRawFolded bool
+ isLiteral bool
+ isFolded bool
+ isSingleLine bool
+ literalOpt string
+}
+
+var (
+ ctxPool = sync.Pool{
+ New: func() interface{} {
+ return createContext()
+ },
+ }
+)
+
+func createContext() *Context {
+ return &Context{
+ idx: 0,
+ tokens: token.Tokens{},
+ isSingleLine: true,
+ }
+}
+
+func newContext(src []rune) *Context {
+ ctx := ctxPool.Get().(*Context)
+ ctx.reset(src)
+ return ctx
+}
+
+func (c *Context) release() {
+ ctxPool.Put(c)
+}
+
+func (c *Context) reset(src []rune) {
+ c.idx = 0
+ c.size = len(src)
+ c.src = src
+ c.tokens = c.tokens[:0]
+ c.resetBuffer()
+ c.isSingleLine = true
+}
+
+func (c *Context) resetBuffer() {
+ c.buf = c.buf[:0]
+ c.obuf = c.obuf[:0]
+ c.notSpaceCharPos = 0
+ c.notSpaceOrgCharPos = 0
+}
+
+func (c *Context) isSaveIndentMode() bool {
+ return c.isLiteral || c.isFolded || c.isRawFolded
+}
+
+func (c *Context) breakLiteral() {
+ c.isLiteral = false
+ c.isRawFolded = false
+ c.isFolded = false
+ c.literalOpt = ""
+}
+
+func (c *Context) addToken(tk *token.Token) {
+ if tk == nil {
+ return
+ }
+ c.tokens = append(c.tokens, tk)
+}
+
+func (c *Context) addBuf(r rune) {
+ if len(c.buf) == 0 && r == ' ' {
+ return
+ }
+ c.buf = append(c.buf, r)
+ if r != ' ' && r != '\t' {
+ c.notSpaceCharPos = len(c.buf)
+ }
+}
+
+func (c *Context) addOriginBuf(r rune) {
+ c.obuf = append(c.obuf, r)
+ if r != ' ' && r != '\t' {
+ c.notSpaceOrgCharPos = len(c.obuf)
+ }
+}
+
+func (c *Context) removeRightSpaceFromBuf() int {
+ trimmedBuf := c.obuf[:c.notSpaceOrgCharPos]
+ buflen := len(trimmedBuf)
+ diff := len(c.obuf) - buflen
+ if diff > 0 {
+ c.obuf = c.obuf[:buflen]
+ c.buf = c.bufferedSrc()
+ }
+ return diff
+}
+
+func (c *Context) isDocument() bool {
+ return c.isLiteral || c.isFolded || c.isRawFolded
+}
+
+func (c *Context) isEOS() bool {
+ return len(c.src)-1 <= c.idx
+}
+
+func (c *Context) isNextEOS() bool {
+ return len(c.src)-1 <= c.idx+1
+}
+
+func (c *Context) next() bool {
+ return c.idx < c.size
+}
+
+func (c *Context) source(s, e int) string {
+ return string(c.src[s:e])
+}
+
+func (c *Context) previousChar() rune {
+ if c.idx > 0 {
+ return c.src[c.idx-1]
+ }
+ return rune(0)
+}
+
+func (c *Context) currentChar() rune {
+ return c.src[c.idx]
+}
+
+func (c *Context) nextChar() rune {
+ if c.size > c.idx+1 {
+ return c.src[c.idx+1]
+ }
+ return rune(0)
+}
+
+func (c *Context) repeatNum(r rune) int {
+ cnt := 0
+ for i := c.idx; i < c.size; i++ {
+ if c.src[i] == r {
+ cnt++
+ } else {
+ break
+ }
+ }
+ return cnt
+}
+
+func (c *Context) progress(num int) {
+ c.idx += num
+}
+
+func (c *Context) nextPos() int {
+ return c.idx + 1
+}
+
+func (c *Context) existsBuffer() bool {
+ return len(c.bufferedSrc()) != 0
+}
+
+func (c *Context) bufferedSrc() []rune {
+ src := c.buf[:c.notSpaceCharPos]
+ if len(src) > 0 && src[len(src)-1] == '\n' && c.isDocument() && c.literalOpt == "-" {
+ // remove end '\n' character
+ src = src[:len(src)-1]
+ }
+ return src
+}
+
+func (c *Context) bufferedToken(pos *token.Position) *token.Token {
+ if c.idx == 0 {
+ return nil
+ }
+ source := c.bufferedSrc()
+ if len(source) == 0 {
+ return nil
+ }
+ var tk *token.Token
+ if c.isDocument() {
+ tk = token.String(string(source), string(c.obuf), pos)
+ } else {
+ tk = token.New(string(source), string(c.obuf), pos)
+ }
+ c.resetBuffer()
+ return tk
+}
diff --git a/vendor/github.com/goccy/go-yaml/scanner/scanner.go b/vendor/github.com/goccy/go-yaml/scanner/scanner.go
new file mode 100644
index 0000000..1e09190
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/scanner/scanner.go
@@ -0,0 +1,876 @@
+package scanner
+
+import (
+ "io"
+ "strings"
+
+ "github.com/goccy/go-yaml/token"
+ "golang.org/x/xerrors"
+)
+
+// IndentState state for indent
+type IndentState int
+
+const (
+ // IndentStateEqual equals previous indent
+ IndentStateEqual IndentState = iota
+ // IndentStateUp more indent than previous
+ IndentStateUp
+ // IndentStateDown less indent than previous
+ IndentStateDown
+ // IndentStateKeep uses not indent token
+ IndentStateKeep
+)
+
+// Scanner holds the scanner's internal state while processing a given text.
+// It can be allocated as part of another data structure but must be initialized via Init before use.
+type Scanner struct {
+ source []rune
+ sourcePos int
+ sourceSize int
+ line int
+ column int
+ offset int
+ prevIndentLevel int
+ prevIndentNum int
+ prevIndentColumn int
+ docStartColumn int
+ indentLevel int
+ indentNum int
+ isFirstCharAtLine bool
+ isAnchor bool
+ startedFlowSequenceNum int
+ startedFlowMapNum int
+ indentState IndentState
+ savedPos *token.Position
+}
+
+func (s *Scanner) pos() *token.Position {
+ return &token.Position{
+ Line: s.line,
+ Column: s.column,
+ Offset: s.offset,
+ IndentNum: s.indentNum,
+ IndentLevel: s.indentLevel,
+ }
+}
+
+func (s *Scanner) bufferedToken(ctx *Context) *token.Token {
+ if s.savedPos != nil {
+ tk := ctx.bufferedToken(s.savedPos)
+ s.savedPos = nil
+ return tk
+ }
+ size := len(ctx.buf)
+ return ctx.bufferedToken(&token.Position{
+ Line: s.line,
+ Column: s.column - size,
+ Offset: s.offset - size,
+ IndentNum: s.indentNum,
+ IndentLevel: s.indentLevel,
+ })
+}
+
+func (s *Scanner) progressColumn(ctx *Context, num int) {
+ s.column += num
+ s.offset += num
+ ctx.progress(num)
+}
+
+func (s *Scanner) progressLine(ctx *Context) {
+ s.column = 1
+ s.line++
+ s.offset++
+ s.indentNum = 0
+ s.isFirstCharAtLine = true
+ s.isAnchor = false
+ ctx.progress(1)
+}
+
+func (s *Scanner) isNeededKeepPreviousIndentNum(ctx *Context, c rune) bool {
+ if !s.isChangedToIndentStateUp() {
+ return false
+ }
+ if ctx.isDocument() {
+ return true
+ }
+ if c == '-' && ctx.existsBuffer() {
+ return true
+ }
+ return false
+}
+
+func (s *Scanner) isNewLineChar(c rune) bool {
+ if c == '\n' {
+ return true
+ }
+ if c == '\r' {
+ return true
+ }
+ return false
+}
+
+func (s *Scanner) newLineCount(src []rune) int {
+ size := len(src)
+ cnt := 0
+ for i := 0; i < size; i++ {
+ c := src[i]
+ switch c {
+ case '\r':
+ if i+1 < size && src[i+1] == '\n' {
+ i++
+ }
+ cnt++
+ case '\n':
+ cnt++
+ }
+ }
+ return cnt
+}
+
+func (s *Scanner) updateIndentState(ctx *Context) {
+ indentNumBasedIndentState := s.indentState
+ if s.prevIndentNum < s.indentNum {
+ s.indentLevel = s.prevIndentLevel + 1
+ indentNumBasedIndentState = IndentStateUp
+ } else if s.prevIndentNum == s.indentNum {
+ s.indentLevel = s.prevIndentLevel
+ indentNumBasedIndentState = IndentStateEqual
+ } else {
+ indentNumBasedIndentState = IndentStateDown
+ if s.prevIndentLevel > 0 {
+ s.indentLevel = s.prevIndentLevel - 1
+ }
+ }
+
+ if s.prevIndentColumn > 0 {
+ if s.prevIndentColumn < s.column {
+ s.indentState = IndentStateUp
+ } else if s.prevIndentColumn != s.column || indentNumBasedIndentState != IndentStateEqual {
+ // The following case ( current position is 'd' ), some variables becomes like here
+ // - prevIndentColumn: 1 of 'a'
+ // - indentNumBasedIndentState: IndentStateDown because d's indentNum(1) is less than c's indentNum(3).
+ // Therefore, s.prevIndentColumn(1) == s.column(1) is true, but we want to treat this as IndentStateDown.
+ // So, we look also current indentState value by the above prevIndentNum based logic, and determins finally indentState.
+ // ---
+ // a:
+ // b
+ // c
+ // d: e
+ // ^
+ s.indentState = IndentStateDown
+ } else {
+ s.indentState = IndentStateEqual
+ }
+ } else {
+ s.indentState = indentNumBasedIndentState
+ }
+}
+
+func (s *Scanner) updateIndent(ctx *Context, c rune) {
+ if s.isFirstCharAtLine && s.isNewLineChar(c) && ctx.isDocument() {
+ return
+ }
+ if s.isFirstCharAtLine && c == ' ' {
+ s.indentNum++
+ return
+ }
+ if !s.isFirstCharAtLine {
+ s.indentState = IndentStateKeep
+ return
+ }
+ s.updateIndentState(ctx)
+ s.isFirstCharAtLine = false
+ if s.isNeededKeepPreviousIndentNum(ctx, c) {
+ return
+ }
+ if s.indentState != IndentStateUp {
+ s.prevIndentColumn = 0
+ }
+ s.prevIndentNum = s.indentNum
+ s.prevIndentLevel = s.indentLevel
+}
+
+func (s *Scanner) isChangedToIndentStateDown() bool {
+ return s.indentState == IndentStateDown
+}
+
+func (s *Scanner) isChangedToIndentStateUp() bool {
+ return s.indentState == IndentStateUp
+}
+
+func (s *Scanner) isChangedToIndentStateEqual() bool {
+ return s.indentState == IndentStateEqual
+}
+
+func (s *Scanner) addBufferedTokenIfExists(ctx *Context) {
+ ctx.addToken(s.bufferedToken(ctx))
+}
+
+func (s *Scanner) breakLiteral(ctx *Context) {
+ s.docStartColumn = 0
+ ctx.breakLiteral()
+}
+
+func (s *Scanner) scanSingleQuote(ctx *Context) (tk *token.Token, pos int) {
+ ctx.addOriginBuf('\'')
+ srcpos := s.pos()
+ startIndex := ctx.idx + 1
+ src := ctx.src
+ size := len(src)
+ value := []rune{}
+ isFirstLineChar := false
+ isNewLine := false
+ for idx := startIndex; idx < size; idx++ {
+ if !isNewLine {
+ s.progressColumn(ctx, 1)
+ } else {
+ isNewLine = false
+ }
+ c := src[idx]
+ pos = idx + 1
+ ctx.addOriginBuf(c)
+ if s.isNewLineChar(c) {
+ value = append(value, ' ')
+ isFirstLineChar = true
+ isNewLine = true
+ s.progressLine(ctx)
+ continue
+ } else if c == ' ' && isFirstLineChar {
+ continue
+ } else if c != '\'' {
+ value = append(value, c)
+ isFirstLineChar = false
+ continue
+ }
+ if idx+1 < len(ctx.src) && ctx.src[idx+1] == '\'' {
+ // '' handle as ' character
+ value = append(value, c)
+ ctx.addOriginBuf(c)
+ idx++
+ continue
+ }
+ s.progressColumn(ctx, 1)
+ tk = token.SingleQuote(string(value), string(ctx.obuf), srcpos)
+ pos = idx - startIndex + 1
+ return
+ }
+ return
+}
+
+func hexToInt(b rune) int {
+ if b >= 'A' && b <= 'F' {
+ return int(b) - 'A' + 10
+ }
+ if b >= 'a' && b <= 'f' {
+ return int(b) - 'a' + 10
+ }
+ return int(b) - '0'
+}
+
+func hexRunesToInt(b []rune) int {
+ sum := 0
+ for i := 0; i < len(b); i++ {
+ sum += hexToInt(b[i]) << (uint(len(b)-i-1) * 4)
+ }
+ return sum
+}
+
+func (s *Scanner) scanDoubleQuote(ctx *Context) (tk *token.Token, pos int) {
+ ctx.addOriginBuf('"')
+ srcpos := s.pos()
+ startIndex := ctx.idx + 1
+ src := ctx.src
+ size := len(src)
+ value := []rune{}
+ isFirstLineChar := false
+ isNewLine := false
+ for idx := startIndex; idx < size; idx++ {
+ if !isNewLine {
+ s.progressColumn(ctx, 1)
+ } else {
+ isNewLine = false
+ }
+ c := src[idx]
+ pos = idx + 1
+ ctx.addOriginBuf(c)
+ if s.isNewLineChar(c) {
+ value = append(value, ' ')
+ isFirstLineChar = true
+ isNewLine = true
+ s.progressLine(ctx)
+ continue
+ } else if c == ' ' && isFirstLineChar {
+ continue
+ } else if c == '\\' {
+ isFirstLineChar = false
+ if idx+1 < size {
+ nextChar := src[idx+1]
+ switch nextChar {
+ case 'b':
+ ctx.addOriginBuf(nextChar)
+ value = append(value, '\b')
+ idx++
+ continue
+ case 'e':
+ ctx.addOriginBuf(nextChar)
+ value = append(value, '\x1B')
+ idx++
+ continue
+ case 'f':
+ ctx.addOriginBuf(nextChar)
+ value = append(value, '\f')
+ idx++
+ continue
+ case 'n':
+ ctx.addOriginBuf(nextChar)
+ value = append(value, '\n')
+ idx++
+ continue
+ case 'v':
+ ctx.addOriginBuf(nextChar)
+ value = append(value, '\v')
+ idx++
+ continue
+ case 'L': // LS (#x2028)
+ ctx.addOriginBuf(nextChar)
+ value = append(value, []rune{'\xE2', '\x80', '\xA8'}...)
+ idx++
+ continue
+ case 'N': // NEL (#x85)
+ ctx.addOriginBuf(nextChar)
+ value = append(value, []rune{'\xC2', '\x85'}...)
+ idx++
+ continue
+ case 'P': // PS (#x2029)
+ ctx.addOriginBuf(nextChar)
+ value = append(value, []rune{'\xE2', '\x80', '\xA9'}...)
+ idx++
+ continue
+ case '_': // #xA0
+ ctx.addOriginBuf(nextChar)
+ value = append(value, []rune{'\xC2', '\xA0'}...)
+ idx++
+ continue
+ case '"':
+ ctx.addOriginBuf(nextChar)
+ value = append(value, nextChar)
+ idx++
+ continue
+ case 'x':
+ if idx+3 >= size {
+ // TODO: need to return error
+ //err = xerrors.New("invalid escape character \\x")
+ return
+ }
+ codeNum := hexRunesToInt(src[idx+2 : idx+4])
+ value = append(value, rune(codeNum))
+ idx += 3
+ continue
+ case 'u':
+ if idx+5 >= size {
+ // TODO: need to return error
+ //err = xerrors.New("invalid escape character \\u")
+ return
+ }
+ codeNum := hexRunesToInt(src[idx+2 : idx+6])
+ value = append(value, rune(codeNum))
+ idx += 5
+ continue
+ case 'U':
+ if idx+9 >= size {
+ // TODO: need to return error
+ //err = xerrors.New("invalid escape character \\U")
+ return
+ }
+ codeNum := hexRunesToInt(src[idx+2 : idx+10])
+ value = append(value, rune(codeNum))
+ idx += 9
+ continue
+ case '\\':
+ ctx.addOriginBuf(nextChar)
+ idx++
+ }
+ }
+ value = append(value, c)
+ continue
+ } else if c != '"' {
+ value = append(value, c)
+ isFirstLineChar = false
+ continue
+ }
+ s.progressColumn(ctx, 1)
+ tk = token.DoubleQuote(string(value), string(ctx.obuf), srcpos)
+ pos = idx - startIndex + 1
+ return
+ }
+ return
+}
+
+func (s *Scanner) scanQuote(ctx *Context, ch rune) (tk *token.Token, pos int) {
+ if ch == '\'' {
+ return s.scanSingleQuote(ctx)
+ }
+ return s.scanDoubleQuote(ctx)
+}
+
+func (s *Scanner) isMergeKey(ctx *Context) bool {
+ if ctx.repeatNum('<') != 2 {
+ return false
+ }
+ src := ctx.src
+ size := len(src)
+ for idx := ctx.idx + 2; idx < size; idx++ {
+ c := src[idx]
+ if c == ' ' {
+ continue
+ }
+ if c != ':' {
+ return false
+ }
+ if idx+1 < size {
+ nc := src[idx+1]
+ if nc == ' ' || s.isNewLineChar(nc) {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+func (s *Scanner) scanTag(ctx *Context) (tk *token.Token, pos int) {
+ ctx.addOriginBuf('!')
+ ctx.progress(1) // skip '!' character
+ for idx, c := range ctx.src[ctx.idx:] {
+ pos = idx + 1
+ ctx.addOriginBuf(c)
+ switch c {
+ case ' ', '\n', '\r':
+ value := ctx.source(ctx.idx-1, ctx.idx+idx)
+ tk = token.Tag(value, string(ctx.obuf), s.pos())
+ pos = len([]rune(value))
+ return
+ }
+ }
+ return
+}
+
+func (s *Scanner) scanComment(ctx *Context) (tk *token.Token, pos int) {
+ ctx.addOriginBuf('#')
+ ctx.progress(1) // skip '#' character
+ for idx, c := range ctx.src[ctx.idx:] {
+ pos = idx + 1
+ ctx.addOriginBuf(c)
+ switch c {
+ case '\n', '\r':
+ if ctx.previousChar() == '\\' {
+ continue
+ }
+ value := ctx.source(ctx.idx, ctx.idx+idx)
+ tk = token.Comment(value, string(ctx.obuf), s.pos())
+ pos = len([]rune(value)) + 1
+ return
+ }
+ }
+ return
+}
+
+func trimCommentFromLiteralOpt(text string) (string, error) {
+ idx := strings.Index(text, "#")
+ if idx < 0 {
+ return text, nil
+ }
+ if idx == 0 {
+ return "", xerrors.New("invalid literal header")
+ }
+ return text[:idx-1], nil
+}
+
+func (s *Scanner) scanLiteral(ctx *Context, c rune) {
+ ctx.addOriginBuf(c)
+ if ctx.isEOS() {
+ if ctx.isLiteral {
+ ctx.addBuf(c)
+ }
+ value := ctx.bufferedSrc()
+ ctx.addToken(token.String(string(value), string(ctx.obuf), s.pos()))
+ ctx.resetBuffer()
+ s.progressColumn(ctx, 1)
+ } else if s.isNewLineChar(c) {
+ if ctx.isLiteral {
+ ctx.addBuf(c)
+ } else {
+ ctx.addBuf(' ')
+ }
+ s.progressLine(ctx)
+ } else if s.isFirstCharAtLine && c == ' ' {
+ if 0 < s.docStartColumn && s.docStartColumn <= s.column {
+ ctx.addBuf(c)
+ }
+ s.progressColumn(ctx, 1)
+ } else {
+ if s.docStartColumn == 0 {
+ s.docStartColumn = s.column
+ }
+ ctx.addBuf(c)
+ s.progressColumn(ctx, 1)
+ }
+}
+
+func (s *Scanner) scanLiteralHeader(ctx *Context) (pos int, err error) {
+ header := ctx.currentChar()
+ ctx.addOriginBuf(header)
+ ctx.progress(1) // skip '|' or '>' character
+ for idx, c := range ctx.src[ctx.idx:] {
+ pos = idx
+ ctx.addOriginBuf(c)
+ switch c {
+ case '\n', '\r':
+ value := ctx.source(ctx.idx, ctx.idx+idx)
+ opt := strings.TrimRight(value, " ")
+ orgOptLen := len(opt)
+ opt, err = trimCommentFromLiteralOpt(opt)
+ if err != nil {
+ return
+ }
+ switch opt {
+ case "", "+", "-",
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9":
+ hasComment := len(opt) < orgOptLen
+ if header == '|' {
+ if hasComment {
+ commentLen := orgOptLen - len(opt)
+ headerPos := strings.Index(string(ctx.obuf), "|")
+ litBuf := ctx.obuf[:len(ctx.obuf)-commentLen-headerPos]
+ commentBuf := ctx.obuf[len(litBuf):]
+ ctx.addToken(token.Literal("|"+opt, string(litBuf), s.pos()))
+ s.column += len(litBuf)
+ s.offset += len(litBuf)
+ commentHeader := strings.Index(value, "#")
+ ctx.addToken(token.Comment(string(value[commentHeader+1:]), string(commentBuf), s.pos()))
+ } else {
+ ctx.addToken(token.Literal("|"+opt, string(ctx.obuf), s.pos()))
+ }
+ ctx.isLiteral = true
+ } else if header == '>' {
+ if hasComment {
+ commentLen := orgOptLen - len(opt)
+ headerPos := strings.Index(string(ctx.obuf), ">")
+ foldedBuf := ctx.obuf[:len(ctx.obuf)-commentLen-headerPos]
+ commentBuf := ctx.obuf[len(foldedBuf):]
+ ctx.addToken(token.Folded(">"+opt, string(foldedBuf), s.pos()))
+ s.column += len(foldedBuf)
+ s.offset += len(foldedBuf)
+ commentHeader := strings.Index(value, "#")
+ ctx.addToken(token.Comment(string(value[commentHeader+1:]), string(commentBuf), s.pos()))
+ } else {
+ ctx.addToken(token.Folded(">"+opt, string(ctx.obuf), s.pos()))
+ }
+ ctx.isFolded = true
+ }
+ s.indentState = IndentStateKeep
+ ctx.resetBuffer()
+ ctx.literalOpt = opt
+ return
+ }
+ break
+ }
+ }
+ err = xerrors.New("invalid literal header")
+ return
+}
+
+func (s *Scanner) scanNewLine(ctx *Context, c rune) {
+ if len(ctx.buf) > 0 && s.savedPos == nil {
+ s.savedPos = s.pos()
+ s.savedPos.Column -= len(ctx.bufferedSrc())
+ }
+
+ // if the following case, origin buffer has unnecessary two spaces.
+ // So, `removeRightSpaceFromOriginBuf` remove them, also fix column number too.
+ // ---
+ // a:[space][space]
+ // b: c
+ removedNum := ctx.removeRightSpaceFromBuf()
+ if removedNum > 0 {
+ s.column -= removedNum
+ s.offset -= removedNum
+ if s.savedPos != nil {
+ s.savedPos.Column -= removedNum
+ }
+ }
+
+ if ctx.isEOS() {
+ s.addBufferedTokenIfExists(ctx)
+ } else if s.isAnchor {
+ s.addBufferedTokenIfExists(ctx)
+ }
+ ctx.addBuf(' ')
+ ctx.addOriginBuf(c)
+ ctx.isSingleLine = false
+ s.progressLine(ctx)
+}
+
+func (s *Scanner) scan(ctx *Context) (pos int) {
+ for ctx.next() {
+ pos = ctx.nextPos()
+ c := ctx.currentChar()
+ s.updateIndent(ctx, c)
+ if ctx.isDocument() {
+ if s.isChangedToIndentStateEqual() ||
+ s.isChangedToIndentStateDown() {
+ s.addBufferedTokenIfExists(ctx)
+ s.breakLiteral(ctx)
+ } else {
+ s.scanLiteral(ctx, c)
+ continue
+ }
+ } else if s.isChangedToIndentStateDown() {
+ s.addBufferedTokenIfExists(ctx)
+ } else if s.isChangedToIndentStateEqual() {
+ // if first character is new line character, buffer expect to raw folded literal
+ if len(ctx.obuf) > 0 && s.newLineCount(ctx.obuf) <= 1 {
+ // doesn't raw folded literal
+ s.addBufferedTokenIfExists(ctx)
+ }
+ }
+ switch c {
+ case '{':
+ if !ctx.existsBuffer() {
+ ctx.addOriginBuf(c)
+ ctx.addToken(token.MappingStart(string(ctx.obuf), s.pos()))
+ s.startedFlowMapNum++
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case '}':
+ if !ctx.existsBuffer() || s.startedFlowMapNum > 0 {
+ ctx.addToken(s.bufferedToken(ctx))
+ ctx.addOriginBuf(c)
+ ctx.addToken(token.MappingEnd(string(ctx.obuf), s.pos()))
+ s.startedFlowMapNum--
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case '.':
+ if s.indentNum == 0 && s.column == 1 && ctx.repeatNum('.') == 3 {
+ ctx.addToken(token.DocumentEnd(string(ctx.obuf)+"...", s.pos()))
+ s.progressColumn(ctx, 3)
+ pos += 2
+ return
+ }
+ case '<':
+ if s.isMergeKey(ctx) {
+ s.prevIndentColumn = s.column
+ ctx.addToken(token.MergeKey(string(ctx.obuf)+"<<", s.pos()))
+ s.progressColumn(ctx, 1)
+ pos++
+ return
+ }
+ case '-':
+ if s.indentNum == 0 && s.column == 1 && ctx.repeatNum('-') == 3 {
+ s.addBufferedTokenIfExists(ctx)
+ ctx.addToken(token.DocumentHeader(string(ctx.obuf)+"---", s.pos()))
+ s.progressColumn(ctx, 3)
+ pos += 2
+ return
+ }
+ if ctx.existsBuffer() && s.isChangedToIndentStateUp() {
+ // raw folded
+ ctx.isRawFolded = true
+ ctx.addBuf(c)
+ ctx.addOriginBuf(c)
+ s.progressColumn(ctx, 1)
+ continue
+ }
+ if ctx.existsBuffer() {
+ // '-' is literal
+ ctx.addBuf(c)
+ ctx.addOriginBuf(c)
+ s.progressColumn(ctx, 1)
+ continue
+ }
+ nc := ctx.nextChar()
+ if nc == ' ' || s.isNewLineChar(nc) {
+ s.addBufferedTokenIfExists(ctx)
+ ctx.addOriginBuf(c)
+ tk := token.SequenceEntry(string(ctx.obuf), s.pos())
+ s.prevIndentColumn = tk.Position.Column
+ ctx.addToken(tk)
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case '[':
+ if !ctx.existsBuffer() {
+ ctx.addOriginBuf(c)
+ ctx.addToken(token.SequenceStart(string(ctx.obuf), s.pos()))
+ s.startedFlowSequenceNum++
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case ']':
+ if !ctx.existsBuffer() || s.startedFlowSequenceNum > 0 {
+ s.addBufferedTokenIfExists(ctx)
+ ctx.addOriginBuf(c)
+ ctx.addToken(token.SequenceEnd(string(ctx.obuf), s.pos()))
+ s.startedFlowSequenceNum--
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case ',':
+ if s.startedFlowSequenceNum > 0 || s.startedFlowMapNum > 0 {
+ s.addBufferedTokenIfExists(ctx)
+ ctx.addOriginBuf(c)
+ ctx.addToken(token.CollectEntry(string(ctx.obuf), s.pos()))
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case ':':
+ nc := ctx.nextChar()
+ if s.startedFlowMapNum > 0 || nc == ' ' || s.isNewLineChar(nc) || ctx.isNextEOS() {
+ // mapping value
+ tk := s.bufferedToken(ctx)
+ if tk != nil {
+ s.prevIndentColumn = tk.Position.Column
+ ctx.addToken(tk)
+ }
+ ctx.addToken(token.MappingValue(s.pos()))
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case '|', '>':
+ if !ctx.existsBuffer() {
+ progress, err := s.scanLiteralHeader(ctx)
+ if err != nil {
+ // TODO: returns syntax error object
+ return
+ }
+ s.progressColumn(ctx, progress)
+ s.progressLine(ctx)
+ continue
+ }
+ case '!':
+ if !ctx.existsBuffer() {
+ token, progress := s.scanTag(ctx)
+ ctx.addToken(token)
+ s.progressColumn(ctx, progress)
+ if c := ctx.previousChar(); s.isNewLineChar(c) {
+ s.progressLine(ctx)
+ }
+ pos += progress
+ return
+ }
+ case '%':
+ if !ctx.existsBuffer() && s.indentNum == 0 {
+ ctx.addToken(token.Directive(string(ctx.obuf)+"%", s.pos()))
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case '?':
+ nc := ctx.nextChar()
+ if !ctx.existsBuffer() && nc == ' ' {
+ ctx.addToken(token.MappingKey(s.pos()))
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case '&':
+ if !ctx.existsBuffer() {
+ s.addBufferedTokenIfExists(ctx)
+ ctx.addOriginBuf(c)
+ ctx.addToken(token.Anchor(string(ctx.obuf), s.pos()))
+ s.progressColumn(ctx, 1)
+ s.isAnchor = true
+ return
+ }
+ case '*':
+ if !ctx.existsBuffer() {
+ s.addBufferedTokenIfExists(ctx)
+ ctx.addOriginBuf(c)
+ ctx.addToken(token.Alias(string(ctx.obuf), s.pos()))
+ s.progressColumn(ctx, 1)
+ return
+ }
+ case '#':
+ if !ctx.existsBuffer() || ctx.previousChar() == ' ' {
+ s.addBufferedTokenIfExists(ctx)
+ token, progress := s.scanComment(ctx)
+ ctx.addToken(token)
+ s.progressColumn(ctx, progress)
+ s.progressLine(ctx)
+ pos += progress
+ return
+ }
+ case '\'', '"':
+ if !ctx.existsBuffer() {
+ token, progress := s.scanQuote(ctx, c)
+ ctx.addToken(token)
+ pos += progress
+ return
+ }
+ case '\r', '\n':
+ // There is no problem that we ignore CR which followed by LF and normalize it to LF, because of following YAML1.2 spec.
+ // > Line breaks inside scalar content must be normalized by the YAML processor. Each such line break must be parsed into a single line feed character.
+ // > Outside scalar content, YAML allows any line break to be used to terminate lines.
+ // > -- https://yaml.org/spec/1.2/spec.html
+ if c == '\r' && ctx.nextChar() == '\n' {
+ ctx.addOriginBuf('\r')
+ ctx.progress(1)
+ c = '\n'
+ }
+ s.scanNewLine(ctx, c)
+ continue
+ case ' ':
+ if ctx.isSaveIndentMode() || (!s.isAnchor && !s.isFirstCharAtLine) {
+ ctx.addBuf(c)
+ ctx.addOriginBuf(c)
+ s.progressColumn(ctx, 1)
+ continue
+ }
+ if s.isFirstCharAtLine {
+ s.progressColumn(ctx, 1)
+ ctx.addOriginBuf(c)
+ continue
+ }
+ s.addBufferedTokenIfExists(ctx)
+ pos-- // to rescan white space at next scanning for adding white space to next buffer.
+ s.isAnchor = false
+ return
+ }
+ ctx.addBuf(c)
+ ctx.addOriginBuf(c)
+ s.progressColumn(ctx, 1)
+ }
+ s.addBufferedTokenIfExists(ctx)
+ return
+}
+
+// Init prepares the scanner s to tokenize the text src by setting the scanner at the beginning of src.
+func (s *Scanner) Init(text string) {
+ src := []rune(text)
+ s.source = src
+ s.sourcePos = 0
+ s.sourceSize = len(src)
+ s.line = 1
+ s.column = 1
+ s.offset = 1
+ s.prevIndentLevel = 0
+ s.prevIndentNum = 0
+ s.prevIndentColumn = 0
+ s.indentLevel = 0
+ s.indentNum = 0
+ s.isFirstCharAtLine = true
+}
+
+// Scan scans the next token and returns the token collection. The source end is indicated by io.EOF.
+func (s *Scanner) Scan() (token.Tokens, error) {
+ if s.sourcePos >= s.sourceSize {
+ return nil, io.EOF
+ }
+ ctx := newContext(s.source[s.sourcePos:])
+ defer ctx.release()
+ progress := s.scan(ctx)
+ s.sourcePos += progress
+ var tokens token.Tokens
+ tokens = append(tokens, ctx.tokens...)
+ return tokens, nil
+}
diff --git a/vendor/github.com/goccy/go-yaml/stdlib_quote.go b/vendor/github.com/goccy/go-yaml/stdlib_quote.go
new file mode 100644
index 0000000..be50ae6
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/stdlib_quote.go
@@ -0,0 +1,103 @@
+// Copied and trimmed down from https://github.com/golang/go/blob/e3769299cd3484e018e0e2a6e1b95c2b18ce4f41/src/strconv/quote.go
+// We want to use the standard library's private "quoteWith" function rather than write our own so that we get robust unicode support.
+// Every private function called by quoteWith was copied.
+// There are 2 modifications to simplify the code:
+// 1. The unicode.IsPrint function was substituted for the custom implementation of IsPrint
+// 2. All code paths reachable only when ASCIIonly or grphicOnly are set to true were removed.
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package yaml
+
+import (
+ "unicode"
+ "unicode/utf8"
+)
+
+const (
+ lowerhex = "0123456789abcdef"
+)
+
+func quoteWith(s string, quote byte) string {
+ return string(appendQuotedWith(make([]byte, 0, 3*len(s)/2), s, quote))
+}
+
+func appendQuotedWith(buf []byte, s string, quote byte) []byte {
+ // Often called with big strings, so preallocate. If there's quoting,
+ // this is conservative but still helps a lot.
+ if cap(buf)-len(buf) < len(s) {
+ nBuf := make([]byte, len(buf), len(buf)+1+len(s)+1)
+ copy(nBuf, buf)
+ buf = nBuf
+ }
+ buf = append(buf, quote)
+ for width := 0; len(s) > 0; s = s[width:] {
+ r := rune(s[0])
+ width = 1
+ if r >= utf8.RuneSelf {
+ r, width = utf8.DecodeRuneInString(s)
+ }
+ if width == 1 && r == utf8.RuneError {
+ buf = append(buf, `\x`...)
+ buf = append(buf, lowerhex[s[0]>>4])
+ buf = append(buf, lowerhex[s[0]&0xF])
+ continue
+ }
+ buf = appendEscapedRune(buf, r, quote)
+ }
+ buf = append(buf, quote)
+ return buf
+}
+
+func appendEscapedRune(buf []byte, r rune, quote byte) []byte {
+ var runeTmp [utf8.UTFMax]byte
+ if r == rune(quote) || r == '\\' { // always backslashed
+ buf = append(buf, '\\')
+ buf = append(buf, byte(r))
+ return buf
+ }
+ if unicode.IsPrint(r) {
+ n := utf8.EncodeRune(runeTmp[:], r)
+ buf = append(buf, runeTmp[:n]...)
+ return buf
+ }
+ switch r {
+ case '\a':
+ buf = append(buf, `\a`...)
+ case '\b':
+ buf = append(buf, `\b`...)
+ case '\f':
+ buf = append(buf, `\f`...)
+ case '\n':
+ buf = append(buf, `\n`...)
+ case '\r':
+ buf = append(buf, `\r`...)
+ case '\t':
+ buf = append(buf, `\t`...)
+ case '\v':
+ buf = append(buf, `\v`...)
+ default:
+ switch {
+ case r < ' ':
+ buf = append(buf, `\x`...)
+ buf = append(buf, lowerhex[byte(r)>>4])
+ buf = append(buf, lowerhex[byte(r)&0xF])
+ case r > utf8.MaxRune:
+ r = 0xFFFD
+ fallthrough
+ case r < 0x10000:
+ buf = append(buf, `\u`...)
+ for s := 12; s >= 0; s -= 4 {
+ buf = append(buf, lowerhex[r>>uint(s)&0xF])
+ }
+ default:
+ buf = append(buf, `\U`...)
+ for s := 28; s >= 0; s -= 4 {
+ buf = append(buf, lowerhex[r>>uint(s)&0xF])
+ }
+ }
+ }
+ return buf
+}
diff --git a/vendor/github.com/goccy/go-yaml/struct.go b/vendor/github.com/goccy/go-yaml/struct.go
new file mode 100644
index 0000000..ac78f31
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/struct.go
@@ -0,0 +1,130 @@
+package yaml
+
+import (
+ "reflect"
+ "strings"
+
+ "golang.org/x/xerrors"
+)
+
+const (
+ // StructTagName tag keyword for Marshal/Unmarshal
+ StructTagName = "yaml"
+)
+
+// StructField information for each the field in structure
+type StructField struct {
+ FieldName string
+ RenderName string
+ AnchorName string
+ AliasName string
+ IsAutoAnchor bool
+ IsAutoAlias bool
+ IsOmitEmpty bool
+ IsFlow bool
+ IsInline bool
+}
+
+func getTag(field reflect.StructField) string {
+ // If struct tag `yaml` exist, use that. If no `yaml`
+ // exists, but `json` does, use that and try the best to
+ // adhere to its rules
+ tag := field.Tag.Get(StructTagName)
+ if tag == "" {
+ tag = field.Tag.Get(`json`)
+ }
+ return tag
+}
+
+func structField(field reflect.StructField) *StructField {
+ tag := getTag(field)
+ fieldName := strings.ToLower(field.Name)
+ options := strings.Split(tag, ",")
+ if len(options) > 0 {
+ if options[0] != "" {
+ fieldName = options[0]
+ }
+ }
+ structField := &StructField{
+ FieldName: field.Name,
+ RenderName: fieldName,
+ }
+ if len(options) > 1 {
+ for _, opt := range options[1:] {
+ switch {
+ case opt == "omitempty":
+ structField.IsOmitEmpty = true
+ case opt == "flow":
+ structField.IsFlow = true
+ case opt == "inline":
+ structField.IsInline = true
+ case strings.HasPrefix(opt, "anchor"):
+ anchor := strings.Split(opt, "=")
+ if len(anchor) > 1 {
+ structField.AnchorName = anchor[1]
+ } else {
+ structField.IsAutoAnchor = true
+ }
+ case strings.HasPrefix(opt, "alias"):
+ alias := strings.Split(opt, "=")
+ if len(alias) > 1 {
+ structField.AliasName = alias[1]
+ } else {
+ structField.IsAutoAlias = true
+ }
+ default:
+ }
+ }
+ }
+ return structField
+}
+
+func isIgnoredStructField(field reflect.StructField) bool {
+ if field.PkgPath != "" && !field.Anonymous {
+ // private field
+ return true
+ }
+ tag := getTag(field)
+ if tag == "-" {
+ return true
+ }
+ return false
+}
+
+type StructFieldMap map[string]*StructField
+
+func (m StructFieldMap) isIncludedRenderName(name string) bool {
+ for _, v := range m {
+ if v.RenderName == name {
+ return true
+ }
+ }
+ return false
+}
+
+func (m StructFieldMap) hasMergeProperty() bool {
+ for _, v := range m {
+ if v.IsOmitEmpty && v.IsInline && v.IsAutoAlias {
+ return true
+ }
+ }
+ return false
+}
+
+func structFieldMap(structType reflect.Type) (StructFieldMap, error) {
+ structFieldMap := StructFieldMap{}
+ renderNameMap := map[string]struct{}{}
+ for i := 0; i < structType.NumField(); i++ {
+ field := structType.Field(i)
+ if isIgnoredStructField(field) {
+ continue
+ }
+ structField := structField(field)
+ if _, exists := renderNameMap[structField.RenderName]; exists {
+ return nil, xerrors.Errorf("duplicated struct field name %s", structField.RenderName)
+ }
+ structFieldMap[structField.FieldName] = structField
+ renderNameMap[structField.RenderName] = struct{}{}
+ }
+ return structFieldMap, nil
+}
diff --git a/vendor/github.com/goccy/go-yaml/token/token.go b/vendor/github.com/goccy/go-yaml/token/token.go
new file mode 100644
index 0000000..f46730b
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/token/token.go
@@ -0,0 +1,1036 @@
+package token
+
+import (
+ "fmt"
+ "strings"
+)
+
+// Character type for character
+type Character byte
+
+const (
+ // SequenceEntryCharacter character for sequence entry
+ SequenceEntryCharacter Character = '-'
+ // MappingKeyCharacter character for mapping key
+ MappingKeyCharacter = '?'
+ // MappingValueCharacter character for mapping value
+ MappingValueCharacter = ':'
+ // CollectEntryCharacter character for collect entry
+ CollectEntryCharacter = ','
+ // SequenceStartCharacter character for sequence start
+ SequenceStartCharacter = '['
+ // SequenceEndCharacter character for sequence end
+ SequenceEndCharacter = ']'
+ // MappingStartCharacter character for mapping start
+ MappingStartCharacter = '{'
+ // MappingEndCharacter character for mapping end
+ MappingEndCharacter = '}'
+ // CommentCharacter character for comment
+ CommentCharacter = '#'
+ // AnchorCharacter character for anchor
+ AnchorCharacter = '&'
+ // AliasCharacter character for alias
+ AliasCharacter = '*'
+ // TagCharacter character for tag
+ TagCharacter = '!'
+ // LiteralCharacter character for literal
+ LiteralCharacter = '|'
+ // FoldedCharacter character for folded
+ FoldedCharacter = '>'
+ // SingleQuoteCharacter character for single quote
+ SingleQuoteCharacter = '\''
+ // DoubleQuoteCharacter character for double quote
+ DoubleQuoteCharacter = '"'
+ // DirectiveCharacter character for directive
+ DirectiveCharacter = '%'
+ // SpaceCharacter character for space
+ SpaceCharacter = ' '
+ // LineBreakCharacter character for line break
+ LineBreakCharacter = '\n'
+)
+
+// Type type identifier for token
+type Type int
+
+const (
+ // UnknownType reserve for invalid type
+ UnknownType Type = iota
+ // DocumentHeaderType type for DocumentHeader token
+ DocumentHeaderType
+ // DocumentEndType type for DocumentEnd token
+ DocumentEndType
+ // SequenceEntryType type for SequenceEntry token
+ SequenceEntryType
+ // MappingKeyType type for MappingKey token
+ MappingKeyType
+ // MappingValueType type for MappingValue token
+ MappingValueType
+ // MergeKeyType type for MergeKey token
+ MergeKeyType
+ // CollectEntryType type for CollectEntry token
+ CollectEntryType
+ // SequenceStartType type for SequenceStart token
+ SequenceStartType
+ // SequenceEndType type for SequenceEnd token
+ SequenceEndType
+ // MappingStartType type for MappingStart token
+ MappingStartType
+ // MappingEndType type for MappingEnd token
+ MappingEndType
+ // CommentType type for Comment token
+ CommentType
+ // AnchorType type for Anchor token
+ AnchorType
+ // AliasType type for Alias token
+ AliasType
+ // TagType type for Tag token
+ TagType
+ // LiteralType type for Literal token
+ LiteralType
+ // FoldedType type for Folded token
+ FoldedType
+ // SingleQuoteType type for SingleQuote token
+ SingleQuoteType
+ // DoubleQuoteType type for DoubleQuote token
+ DoubleQuoteType
+ // DirectiveType type for Directive token
+ DirectiveType
+ // SpaceType type for Space token
+ SpaceType
+ // NullType type for Null token
+ NullType
+ // InfinityType type for Infinity token
+ InfinityType
+ // NanType type for Nan token
+ NanType
+ // IntegerType type for Integer token
+ IntegerType
+ // BinaryIntegerType type for BinaryInteger token
+ BinaryIntegerType
+ // OctetIntegerType type for OctetInteger token
+ OctetIntegerType
+ // HexIntegerType type for HexInteger token
+ HexIntegerType
+ // FloatType type for Float token
+ FloatType
+ // StringType type for String token
+ StringType
+ // BoolType type for Bool token
+ BoolType
+)
+
+// String type identifier to text
+func (t Type) String() string {
+ switch t {
+ case UnknownType:
+ return "Unknown"
+ case DocumentHeaderType:
+ return "DocumentHeader"
+ case DocumentEndType:
+ return "DocumentEnd"
+ case SequenceEntryType:
+ return "SequenceEntry"
+ case MappingKeyType:
+ return "MappingKey"
+ case MappingValueType:
+ return "MappingValue"
+ case MergeKeyType:
+ return "MergeKey"
+ case CollectEntryType:
+ return "CollectEntry"
+ case SequenceStartType:
+ return "SequenceStart"
+ case SequenceEndType:
+ return "SequenceEnd"
+ case MappingStartType:
+ return "MappingStart"
+ case MappingEndType:
+ return "MappingEnd"
+ case CommentType:
+ return "Comment"
+ case AnchorType:
+ return "Anchor"
+ case AliasType:
+ return "Alias"
+ case TagType:
+ return "Tag"
+ case LiteralType:
+ return "Literal"
+ case FoldedType:
+ return "Folded"
+ case SingleQuoteType:
+ return "SingleQuote"
+ case DoubleQuoteType:
+ return "DoubleQuote"
+ case DirectiveType:
+ return "Directive"
+ case SpaceType:
+ return "Space"
+ case StringType:
+ return "String"
+ case BoolType:
+ return "Bool"
+ case IntegerType:
+ return "Integer"
+ case BinaryIntegerType:
+ return "BinaryInteger"
+ case OctetIntegerType:
+ return "OctetInteger"
+ case HexIntegerType:
+ return "HexInteger"
+ case FloatType:
+ return "Float"
+ case NullType:
+ return "Null"
+ case InfinityType:
+ return "Infinity"
+ case NanType:
+ return "Nan"
+ }
+ return ""
+}
+
+// CharacterType type for character category
+type CharacterType int
+
+const (
+ // CharacterTypeIndicator type of indicator character
+ CharacterTypeIndicator CharacterType = iota
+ // CharacterTypeWhiteSpace type of white space character
+ CharacterTypeWhiteSpace
+ // CharacterTypeMiscellaneous type of miscellaneous character
+ CharacterTypeMiscellaneous
+ // CharacterTypeEscaped type of escaped character
+ CharacterTypeEscaped
+)
+
+// String character type identifier to text
+func (c CharacterType) String() string {
+ switch c {
+ case CharacterTypeIndicator:
+ return "Indicator"
+ case CharacterTypeWhiteSpace:
+ return "WhiteSpcae"
+ case CharacterTypeMiscellaneous:
+ return "Miscellaneous"
+ case CharacterTypeEscaped:
+ return "Escaped"
+ }
+ return ""
+}
+
+// Indicator type for indicator
+type Indicator int
+
+const (
+ // NotIndicator not indicator
+ NotIndicator Indicator = iota
+ // BlockStructureIndicator indicator for block structure ( '-', '?', ':' )
+ BlockStructureIndicator
+ // FlowCollectionIndicator indicator for flow collection ( '[', ']', '{', '}', ',' )
+ FlowCollectionIndicator
+ // CommentIndicator indicator for comment ( '#' )
+ CommentIndicator
+ // NodePropertyIndicator indicator for node property ( '!', '&', '*' )
+ NodePropertyIndicator
+ // BlockScalarIndicator indicator for block scalar ( '|', '>' )
+ BlockScalarIndicator
+ // QuotedScalarIndicator indicator for quoted scalar ( ''', '"' )
+ QuotedScalarIndicator
+ // DirectiveIndicator indicator for directive ( '%' )
+ DirectiveIndicator
+ // InvalidUseOfReservedIndicator indicator for invalid use of reserved keyword ( '@', '`' )
+ InvalidUseOfReservedIndicator
+)
+
+// String indicator to text
+func (i Indicator) String() string {
+ switch i {
+ case NotIndicator:
+ return "NotIndicator"
+ case BlockStructureIndicator:
+ return "BlockStructure"
+ case FlowCollectionIndicator:
+ return "FlowCollection"
+ case CommentIndicator:
+ return "Comment"
+ case NodePropertyIndicator:
+ return "NodeProperty"
+ case BlockScalarIndicator:
+ return "BlockScalar"
+ case QuotedScalarIndicator:
+ return "QuotedScalar"
+ case DirectiveIndicator:
+ return "Directive"
+ case InvalidUseOfReservedIndicator:
+ return "InvalidUseOfReserved"
+ }
+ return ""
+}
+
+var (
+ reservedNullKeywords = []string{
+ "null",
+ "Null",
+ "NULL",
+ "~",
+ }
+ reservedBoolKeywords = []string{
+ "true",
+ "True",
+ "TRUE",
+ "false",
+ "False",
+ "FALSE",
+ }
+ reservedInfKeywords = []string{
+ ".inf",
+ ".Inf",
+ ".INF",
+ "-.inf",
+ "-.Inf",
+ "-.INF",
+ }
+ reservedNanKeywords = []string{
+ ".nan",
+ ".NaN",
+ ".NAN",
+ }
+ reservedKeywordMap = map[string]func(string, string, *Position) *Token{}
+)
+
+func reservedKeywordToken(typ Type, value, org string, pos *Position) *Token {
+ return &Token{
+ Type: typ,
+ CharacterType: CharacterTypeMiscellaneous,
+ Indicator: NotIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+func init() {
+ for _, keyword := range reservedNullKeywords {
+ reservedKeywordMap[keyword] = func(value, org string, pos *Position) *Token {
+ return reservedKeywordToken(NullType, value, org, pos)
+ }
+ }
+ for _, keyword := range reservedBoolKeywords {
+ reservedKeywordMap[keyword] = func(value, org string, pos *Position) *Token {
+ return reservedKeywordToken(BoolType, value, org, pos)
+ }
+ }
+ for _, keyword := range reservedInfKeywords {
+ reservedKeywordMap[keyword] = func(value, org string, pos *Position) *Token {
+ return reservedKeywordToken(InfinityType, value, org, pos)
+ }
+ }
+ for _, keyword := range reservedNanKeywords {
+ reservedKeywordMap[keyword] = func(value, org string, pos *Position) *Token {
+ return reservedKeywordToken(NanType, value, org, pos)
+ }
+ }
+}
+
+// ReservedTagKeyword type of reserved tag keyword
+type ReservedTagKeyword string
+
+const (
+ // IntegerTag `!!int` tag
+ IntegerTag ReservedTagKeyword = "!!int"
+ // FloatTag `!!float` tag
+ FloatTag ReservedTagKeyword = "!!float"
+ // NullTag `!!null` tag
+ NullTag ReservedTagKeyword = "!!null"
+ // SequenceTag `!!seq` tag
+ SequenceTag ReservedTagKeyword = "!!seq"
+ // MappingTag `!!map` tag
+ MappingTag ReservedTagKeyword = "!!map"
+ // StringTag `!!str` tag
+ StringTag ReservedTagKeyword = "!!str"
+ // BinaryTag `!!binary` tag
+ BinaryTag ReservedTagKeyword = "!!binary"
+ // OrderedMapTag `!!omap` tag
+ OrderedMapTag ReservedTagKeyword = "!!omap"
+ // SetTag `!!set` tag
+ SetTag ReservedTagKeyword = "!!set"
+ // TimestampTag `!!timestamp` tag
+ TimestampTag ReservedTagKeyword = "!!timestamp"
+)
+
+var (
+ // ReservedTagKeywordMap map for reserved tag keywords
+ ReservedTagKeywordMap = map[ReservedTagKeyword]func(string, string, *Position) *Token{
+ IntegerTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ FloatTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ NullTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ SequenceTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ MappingTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ StringTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ BinaryTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ OrderedMapTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ SetTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ TimestampTag: func(value, org string, pos *Position) *Token {
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ },
+ }
+)
+
+type numType int
+
+const (
+ numTypeNone numType = iota
+ numTypeBinary
+ numTypeOctet
+ numTypeHex
+ numTypeFloat
+)
+
+type numStat struct {
+ isNum bool
+ typ numType
+}
+
+func getNumberStat(str string) *numStat {
+ stat := &numStat{}
+ if str == "" {
+ return stat
+ }
+ if str == "-" || str == "." || str == "+" || str == "_" {
+ return stat
+ }
+ if str[0] == '_' {
+ return stat
+ }
+ dotFound := false
+ isNegative := false
+ isExponent := false
+ if str[0] == '-' {
+ isNegative = true
+ }
+ for idx, c := range str {
+ switch c {
+ case 'x':
+ if (isNegative && idx == 2) || (!isNegative && idx == 1) {
+ continue
+ }
+ case 'o':
+ if (isNegative && idx == 2) || (!isNegative && idx == 1) {
+ continue
+ }
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ continue
+ case 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F':
+ if (len(str) > 2 && str[0] == '0' && str[1] == 'x') ||
+ (len(str) > 3 && isNegative && str[1] == '0' && str[2] == 'x') {
+ // hex number
+ continue
+ }
+ if c == 'b' && ((isNegative && idx == 2) || (!isNegative && idx == 1)) {
+ // binary number
+ continue
+ }
+ if (c == 'e' || c == 'E') && dotFound {
+ // exponent
+ isExponent = true
+ continue
+ }
+ case '.':
+ if dotFound {
+ // multiple dot
+ return stat
+ }
+ dotFound = true
+ continue
+ case '-':
+ if idx == 0 || isExponent {
+ continue
+ }
+ case '+':
+ if idx == 0 || isExponent {
+ continue
+ }
+ case '_':
+ continue
+ }
+ return stat
+ }
+ stat.isNum = true
+ switch {
+ case dotFound:
+ stat.typ = numTypeFloat
+ case strings.HasPrefix(str, "0b") || strings.HasPrefix(str, "-0b"):
+ stat.typ = numTypeBinary
+ case strings.HasPrefix(str, "0x") || strings.HasPrefix(str, "-0x"):
+ stat.typ = numTypeHex
+ case strings.HasPrefix(str, "0o") || strings.HasPrefix(str, "-0o"):
+ stat.typ = numTypeOctet
+ case (len(str) > 1 && str[0] == '0') || (len(str) > 1 && str[0] == '-' && str[1] == '0'):
+ stat.typ = numTypeOctet
+ }
+ return stat
+}
+
+func looksLikeTimeValue(value string) bool {
+ for i, c := range value {
+ switch c {
+ case ':', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ continue
+ case '0':
+ if i == 0 {
+ return false
+ }
+ continue
+ }
+ return false
+ }
+ return true
+}
+
+// IsNeedQuoted whether need quote for passed string or not
+func IsNeedQuoted(value string) bool {
+ if value == "" {
+ return true
+ }
+ if _, exists := reservedKeywordMap[value]; exists {
+ return true
+ }
+ if stat := getNumberStat(value); stat.isNum {
+ return true
+ }
+ first := value[0]
+ switch first {
+ case '*', '&', '[', '{', '}', ']', ',', '!', '|', '>', '%', '\'', '"':
+ return true
+ }
+ last := value[len(value)-1]
+ switch last {
+ case ':':
+ return true
+ }
+ if looksLikeTimeValue(value) {
+ return true
+ }
+ for i, c := range value {
+ switch c {
+ case '#', '\\':
+ return true
+ case ':':
+ if i+1 < len(value) && value[i+1] == ' ' {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+// LiteralBlockHeader detect literal block scalar header
+func LiteralBlockHeader(value string) string {
+ lbc := DetectLineBreakCharacter(value)
+
+ switch {
+ case !strings.Contains(value, lbc):
+ return ""
+ case strings.HasSuffix(value, fmt.Sprintf("%s%s", lbc, lbc)):
+ return "|+"
+ case strings.HasSuffix(value, lbc):
+ return "|"
+ default:
+ return "|-"
+ }
+}
+
+// New create reserved keyword token or number token and other string token
+func New(value string, org string, pos *Position) *Token {
+ fn := reservedKeywordMap[value]
+ if fn != nil {
+ return fn(value, org, pos)
+ }
+ if stat := getNumberStat(value); stat.isNum {
+ tk := &Token{
+ Type: IntegerType,
+ CharacterType: CharacterTypeMiscellaneous,
+ Indicator: NotIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+ switch stat.typ {
+ case numTypeFloat:
+ tk.Type = FloatType
+ case numTypeBinary:
+ tk.Type = BinaryIntegerType
+ case numTypeOctet:
+ tk.Type = OctetIntegerType
+ case numTypeHex:
+ tk.Type = HexIntegerType
+ }
+ return tk
+ }
+ return String(value, org, pos)
+}
+
+// Position type for position in YAML document
+type Position struct {
+ Line int
+ Column int
+ Offset int
+ IndentNum int
+ IndentLevel int
+}
+
+// String position to text
+func (p *Position) String() string {
+ return fmt.Sprintf("[level:%d,line:%d,column:%d,offset:%d]", p.IndentLevel, p.Line, p.Column, p.Offset)
+}
+
+// Token type for token
+type Token struct {
+ Type Type
+ CharacterType CharacterType
+ Indicator Indicator
+ Value string
+ Origin string
+ Position *Position
+ Next *Token
+ Prev *Token
+}
+
+// PreviousType previous token type
+func (t *Token) PreviousType() Type {
+ if t.Prev != nil {
+ return t.Prev.Type
+ }
+ return UnknownType
+}
+
+// NextType next token type
+func (t *Token) NextType() Type {
+ if t.Next != nil {
+ return t.Next.Type
+ }
+ return UnknownType
+}
+
+// AddColumn append column number to current position of column
+func (t *Token) AddColumn(col int) {
+ if t == nil {
+ return
+ }
+ t.Position.Column += col
+}
+
+// Clone copy token ( preserve Prev/Next reference )
+func (t *Token) Clone() *Token {
+ if t == nil {
+ return nil
+ }
+ copied := *t
+ if t.Position != nil {
+ pos := *(t.Position)
+ copied.Position = &pos
+ }
+ return &copied
+}
+
+// Tokens type of token collection
+type Tokens []*Token
+
+func (t *Tokens) add(tk *Token) {
+ tokens := *t
+ if len(tokens) == 0 {
+ tokens = append(tokens, tk)
+ } else {
+ last := tokens[len(tokens)-1]
+ last.Next = tk
+ tk.Prev = last
+ tokens = append(tokens, tk)
+ }
+ *t = tokens
+}
+
+// Add append new some tokens
+func (t *Tokens) Add(tks ...*Token) {
+ for _, tk := range tks {
+ t.add(tk)
+ }
+}
+
+// Dump dump all token structures for debugging
+func (t Tokens) Dump() {
+ for _, tk := range t {
+ fmt.Printf("- %+v\n", tk)
+ }
+}
+
+// String create token for String
+func String(value string, org string, pos *Position) *Token {
+ return &Token{
+ Type: StringType,
+ CharacterType: CharacterTypeMiscellaneous,
+ Indicator: NotIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// SequenceEntry create token for SequenceEntry
+func SequenceEntry(org string, pos *Position) *Token {
+ return &Token{
+ Type: SequenceEntryType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: BlockStructureIndicator,
+ Value: string(SequenceEntryCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// MappingKey create token for MappingKey
+func MappingKey(pos *Position) *Token {
+ return &Token{
+ Type: MappingKeyType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: BlockStructureIndicator,
+ Value: string(MappingKeyCharacter),
+ Origin: string(MappingKeyCharacter),
+ Position: pos,
+ }
+}
+
+// MappingValue create token for MappingValue
+func MappingValue(pos *Position) *Token {
+ return &Token{
+ Type: MappingValueType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: BlockStructureIndicator,
+ Value: string(MappingValueCharacter),
+ Origin: string(MappingValueCharacter),
+ Position: pos,
+ }
+}
+
+// CollectEntry create token for CollectEntry
+func CollectEntry(org string, pos *Position) *Token {
+ return &Token{
+ Type: CollectEntryType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: FlowCollectionIndicator,
+ Value: string(CollectEntryCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// SequenceStart create token for SequenceStart
+func SequenceStart(org string, pos *Position) *Token {
+ return &Token{
+ Type: SequenceStartType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: FlowCollectionIndicator,
+ Value: string(SequenceStartCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// SequenceEnd create token for SequenceEnd
+func SequenceEnd(org string, pos *Position) *Token {
+ return &Token{
+ Type: SequenceEndType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: FlowCollectionIndicator,
+ Value: string(SequenceEndCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// MappingStart create token for MappingStart
+func MappingStart(org string, pos *Position) *Token {
+ return &Token{
+ Type: MappingStartType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: FlowCollectionIndicator,
+ Value: string(MappingStartCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// MappingEnd create token for MappingEnd
+func MappingEnd(org string, pos *Position) *Token {
+ return &Token{
+ Type: MappingEndType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: FlowCollectionIndicator,
+ Value: string(MappingEndCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Comment create token for Comment
+func Comment(value string, org string, pos *Position) *Token {
+ return &Token{
+ Type: CommentType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: CommentIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Anchor create token for Anchor
+func Anchor(org string, pos *Position) *Token {
+ return &Token{
+ Type: AnchorType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: string(AnchorCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Alias create token for Alias
+func Alias(org string, pos *Position) *Token {
+ return &Token{
+ Type: AliasType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: string(AliasCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Tag create token for Tag
+func Tag(value string, org string, pos *Position) *Token {
+ fn := ReservedTagKeywordMap[ReservedTagKeyword(value)]
+ if fn != nil {
+ return fn(value, org, pos)
+ }
+ return &Token{
+ Type: TagType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: NodePropertyIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Literal create token for Literal
+func Literal(value string, org string, pos *Position) *Token {
+ return &Token{
+ Type: LiteralType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: BlockScalarIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Folded create token for Folded
+func Folded(value string, org string, pos *Position) *Token {
+ return &Token{
+ Type: FoldedType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: BlockScalarIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// SingleQuote create token for SingleQuote
+func SingleQuote(value string, org string, pos *Position) *Token {
+ return &Token{
+ Type: SingleQuoteType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: QuotedScalarIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// DoubleQuote create token for DoubleQuote
+func DoubleQuote(value string, org string, pos *Position) *Token {
+ return &Token{
+ Type: DoubleQuoteType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: QuotedScalarIndicator,
+ Value: value,
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Directive create token for Directive
+func Directive(org string, pos *Position) *Token {
+ return &Token{
+ Type: DirectiveType,
+ CharacterType: CharacterTypeIndicator,
+ Indicator: DirectiveIndicator,
+ Value: string(DirectiveCharacter),
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// Space create token for Space
+func Space(pos *Position) *Token {
+ return &Token{
+ Type: SpaceType,
+ CharacterType: CharacterTypeWhiteSpace,
+ Indicator: NotIndicator,
+ Value: string(SpaceCharacter),
+ Origin: string(SpaceCharacter),
+ Position: pos,
+ }
+}
+
+// MergeKey create token for MergeKey
+func MergeKey(org string, pos *Position) *Token {
+ return &Token{
+ Type: MergeKeyType,
+ CharacterType: CharacterTypeMiscellaneous,
+ Indicator: NotIndicator,
+ Value: "<<",
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// DocumentHeader create token for DocumentHeader
+func DocumentHeader(org string, pos *Position) *Token {
+ return &Token{
+ Type: DocumentHeaderType,
+ CharacterType: CharacterTypeMiscellaneous,
+ Indicator: NotIndicator,
+ Value: "---",
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// DocumentEnd create token for DocumentEnd
+func DocumentEnd(org string, pos *Position) *Token {
+ return &Token{
+ Type: DocumentEndType,
+ CharacterType: CharacterTypeMiscellaneous,
+ Indicator: NotIndicator,
+ Value: "...",
+ Origin: org,
+ Position: pos,
+ }
+}
+
+// DetectLineBreakCharacter detect line break character in only one inside scalar content scope.
+func DetectLineBreakCharacter(src string) string {
+ nc := strings.Count(src, "\n")
+ rc := strings.Count(src, "\r")
+ rnc := strings.Count(src, "\r\n")
+ switch {
+ case nc == rnc && rc == rnc:
+ return "\r\n"
+ case rc > nc:
+ return "\r"
+ default:
+ return "\n"
+ }
+}
diff --git a/vendor/github.com/goccy/go-yaml/validate.go b/vendor/github.com/goccy/go-yaml/validate.go
new file mode 100644
index 0000000..20a2d6d
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/validate.go
@@ -0,0 +1,13 @@
+package yaml
+
+// StructValidator need to implement Struct method only
+// ( see https://pkg.go.dev/github.com/go-playground/validator/v10#Validate.Struct )
+type StructValidator interface {
+ Struct(interface{}) error
+}
+
+// FieldError need to implement StructField method only
+// ( see https://pkg.go.dev/github.com/go-playground/validator/v10#FieldError )
+type FieldError interface {
+ StructField() string
+}
diff --git a/vendor/github.com/goccy/go-yaml/yaml.go b/vendor/github.com/goccy/go-yaml/yaml.go
new file mode 100644
index 0000000..6074f9d
--- /dev/null
+++ b/vendor/github.com/goccy/go-yaml/yaml.go
@@ -0,0 +1,250 @@
+package yaml
+
+import (
+ "bytes"
+ "context"
+ "io"
+
+ "github.com/goccy/go-yaml/ast"
+ "github.com/goccy/go-yaml/internal/errors"
+ "golang.org/x/xerrors"
+)
+
+// BytesMarshaler interface may be implemented by types to customize their
+// behavior when being marshaled into a YAML document. The returned value
+// is marshaled in place of the original value implementing Marshaler.
+//
+// If an error is returned by MarshalYAML, the marshaling procedure stops
+// and returns with the provided error.
+type BytesMarshaler interface {
+ MarshalYAML() ([]byte, error)
+}
+
+// BytesMarshalerContext interface use BytesMarshaler with context.Context.
+type BytesMarshalerContext interface {
+ MarshalYAML(context.Context) ([]byte, error)
+}
+
+// InterfaceMarshaler interface has MarshalYAML compatible with github.com/go-yaml/yaml package.
+type InterfaceMarshaler interface {
+ MarshalYAML() (interface{}, error)
+}
+
+// InterfaceMarshalerContext interface use InterfaceMarshaler with context.Context.
+type InterfaceMarshalerContext interface {
+ MarshalYAML(context.Context) (interface{}, error)
+}
+
+// BytesUnmarshaler interface may be implemented by types to customize their
+// behavior when being unmarshaled from a YAML document.
+type BytesUnmarshaler interface {
+ UnmarshalYAML([]byte) error
+}
+
+// BytesUnmarshalerContext interface use BytesUnmarshaler with context.Context.
+type BytesUnmarshalerContext interface {
+ UnmarshalYAML(context.Context, []byte) error
+}
+
+// InterfaceUnmarshaler interface has UnmarshalYAML compatible with github.com/go-yaml/yaml package.
+type InterfaceUnmarshaler interface {
+ UnmarshalYAML(func(interface{}) error) error
+}
+
+// InterfaceUnmarshalerContext interface use InterfaceUnmarshaler with context.Context.
+type InterfaceUnmarshalerContext interface {
+ UnmarshalYAML(context.Context, func(interface{}) error) error
+}
+
+// MapItem is an item in a MapSlice.
+type MapItem struct {
+ Key, Value interface{}
+}
+
+// MapSlice encodes and decodes as a YAML map.
+// The order of keys is preserved when encoding and decoding.
+type MapSlice []MapItem
+
+// ToMap convert to map[interface{}]interface{}.
+func (s MapSlice) ToMap() map[interface{}]interface{} {
+ v := map[interface{}]interface{}{}
+ for _, item := range s {
+ v[item.Key] = item.Value
+ }
+ return v
+}
+
+// Marshal serializes the value provided into a YAML document. The structure
+// of the generated document will reflect the structure of the value itself.
+// Maps and pointers (to struct, string, int, etc) are accepted as the in value.
+//
+// Struct fields are only marshalled if they are exported (have an upper case
+// first letter), and are marshalled using the field name lowercased as the
+// default key. Custom keys may be defined via the "yaml" name in the field
+// tag: the content preceding the first comma is used as the key, and the
+// following comma-separated options are used to tweak the marshalling process.
+// Conflicting names result in a runtime error.
+//
+// The field tag format accepted is:
+//
+// `(...) yaml:"[][,[,]]" (...)`
+//
+// The following flags are currently supported:
+//
+// omitempty Only include the field if it's not set to the zero
+// value for the type or to empty slices or maps.
+// Zero valued structs will be omitted if all their public
+// fields are zero, unless they implement an IsZero
+// method (see the IsZeroer interface type), in which
+// case the field will be included if that method returns true.
+//
+// flow Marshal using a flow style (useful for structs,
+// sequences and maps).
+//
+// inline Inline the field, which must be a struct or a map,
+// causing all of its fields or keys to be processed as if
+// they were part of the outer struct. For maps, keys must
+// not conflict with the yaml keys of other struct fields.
+//
+// anchor Marshal with anchor. If want to define anchor name explicitly, use anchor=name style.
+// Otherwise, if used 'anchor' name only, used the field name lowercased as the anchor name
+//
+// alias Marshal with alias. If want to define alias name explicitly, use alias=name style.
+// Otherwise, If omitted alias name and the field type is pointer type,
+// assigned anchor name automatically from same pointer address.
+//
+// In addition, if the key is "-", the field is ignored.
+//
+// For example:
+//
+// type T struct {
+// F int `yaml:"a,omitempty"`
+// B int
+// }
+// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n"
+// yaml.Marshal(&T{F: 1}) // Returns "a: 1\nb: 0\n"
+//
+func Marshal(v interface{}) ([]byte, error) {
+ return MarshalWithOptions(v)
+}
+
+// MarshalWithOptions serializes the value provided into a YAML document with EncodeOptions.
+func MarshalWithOptions(v interface{}, opts ...EncodeOption) ([]byte, error) {
+ return MarshalContext(context.Background(), v, opts...)
+}
+
+// MarshalContext serializes the value provided into a YAML document with context.Context and EncodeOptions.
+func MarshalContext(ctx context.Context, v interface{}, opts ...EncodeOption) ([]byte, error) {
+ var buf bytes.Buffer
+ if err := NewEncoder(&buf, opts...).EncodeContext(ctx, v); err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal")
+ }
+ return buf.Bytes(), nil
+}
+
+// ValueToNode convert from value to ast.Node.
+func ValueToNode(v interface{}, opts ...EncodeOption) (ast.Node, error) {
+ var buf bytes.Buffer
+ node, err := NewEncoder(&buf, opts...).EncodeToNode(v)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to convert value to node")
+ }
+ return node, nil
+}
+
+// Unmarshal decodes the first document found within the in byte slice
+// and assigns decoded values into the out value.
+//
+// Struct fields are only unmarshalled if they are exported (have an
+// upper case first letter), and are unmarshalled using the field name
+// lowercased as the default key. Custom keys may be defined via the
+// "yaml" name in the field tag: the content preceding the first comma
+// is used as the key, and the following comma-separated options are
+// used to tweak the marshalling process (see Marshal).
+// Conflicting names result in a runtime error.
+//
+// For example:
+//
+// type T struct {
+// F int `yaml:"a,omitempty"`
+// B int
+// }
+// var t T
+// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t)
+//
+// See the documentation of Marshal for the format of tags and a list of
+// supported tag options.
+//
+func Unmarshal(data []byte, v interface{}) error {
+ return UnmarshalWithOptions(data, v)
+}
+
+// UnmarshalWithOptions decodes with DecodeOptions the first document found within the in byte slice
+// and assigns decoded values into the out value.
+func UnmarshalWithOptions(data []byte, v interface{}, opts ...DecodeOption) error {
+ return UnmarshalContext(context.Background(), data, v, opts...)
+}
+
+// UnmarshalContext decodes with context.Context and DecodeOptions.
+func UnmarshalContext(ctx context.Context, data []byte, v interface{}, opts ...DecodeOption) error {
+ dec := NewDecoder(bytes.NewBuffer(data), opts...)
+ if err := dec.DecodeContext(ctx, v); err != nil {
+ if err == io.EOF {
+ return nil
+ }
+ return errors.Wrapf(err, "failed to unmarshal")
+ }
+ return nil
+}
+
+// NodeToValue converts node to the value pointed to by v.
+func NodeToValue(node ast.Node, v interface{}, opts ...DecodeOption) error {
+ var buf bytes.Buffer
+ if err := NewDecoder(&buf, opts...).DecodeFromNode(node, v); err != nil {
+ return errors.Wrapf(err, "failed to convert node to value")
+ }
+ return nil
+}
+
+// FormatError is a utility function that takes advantage of the metadata
+// stored in the errors returned by this package's parser.
+//
+// If the second argument `colored` is true, the error message is colorized.
+// If the third argument `inclSource` is true, the error message will
+// contain snippets of the YAML source that was used.
+func FormatError(e error, colored, inclSource bool) string {
+ var pp errors.PrettyPrinter
+ if xerrors.As(e, &pp) {
+ var buf bytes.Buffer
+ pp.PrettyPrint(&errors.Sink{&buf}, colored, inclSource)
+ return buf.String()
+ }
+
+ return e.Error()
+}
+
+// YAMLToJSON convert YAML bytes to JSON.
+func YAMLToJSON(bytes []byte) ([]byte, error) {
+ var v interface{}
+ if err := UnmarshalWithOptions(bytes, &v, UseOrderedMap()); err != nil {
+ return nil, errors.Wrapf(err, "failed to unmarshal")
+ }
+ out, err := MarshalWithOptions(v, JSON())
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal with json option")
+ }
+ return out, nil
+}
+
+// JSONToYAML convert JSON bytes to YAML.
+func JSONToYAML(bytes []byte) ([]byte, error) {
+ var v interface{}
+ if err := UnmarshalWithOptions(bytes, &v, UseOrderedMap()); err != nil {
+ return nil, errors.Wrapf(err, "failed to unmarshal from json bytes")
+ }
+ out, err := Marshal(v)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal")
+ }
+ return out, nil
+}
diff --git a/vendor/github.com/mattn/go-colorable/LICENSE b/vendor/github.com/mattn/go-colorable/LICENSE
new file mode 100644
index 0000000..91b5cef
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Yasuhiro Matsumoto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/mattn/go-colorable/README.md b/vendor/github.com/mattn/go-colorable/README.md
new file mode 100644
index 0000000..ca04837
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/README.md
@@ -0,0 +1,48 @@
+# go-colorable
+
+[![Build Status](https://github.com/mattn/go-colorable/workflows/test/badge.svg)](https://github.com/mattn/go-colorable/actions?query=workflow%3Atest)
+[![Codecov](https://codecov.io/gh/mattn/go-colorable/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-colorable)
+[![GoDoc](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable)
+[![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable)
+
+Colorable writer for windows.
+
+For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
+This package is possible to handle escape sequence for ansi color on windows.
+
+## Too Bad!
+
+![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png)
+
+
+## So Good!
+
+![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png)
+
+## Usage
+
+```go
+logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
+logrus.SetOutput(colorable.NewColorableStdout())
+
+logrus.Info("succeeded")
+logrus.Warn("not correct")
+logrus.Error("something error")
+logrus.Fatal("panic")
+```
+
+You can compile above code on non-windows OSs.
+
+## Installation
+
+```
+$ go get github.com/mattn/go-colorable
+```
+
+# License
+
+MIT
+
+# Author
+
+Yasuhiro Matsumoto (a.k.a mattn)
diff --git a/vendor/github.com/mattn/go-colorable/colorable_appengine.go b/vendor/github.com/mattn/go-colorable/colorable_appengine.go
new file mode 100644
index 0000000..416d1bb
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/colorable_appengine.go
@@ -0,0 +1,38 @@
+//go:build appengine
+// +build appengine
+
+package colorable
+
+import (
+ "io"
+ "os"
+
+ _ "github.com/mattn/go-isatty"
+)
+
+// NewColorable returns new instance of Writer which handles escape sequence.
+func NewColorable(file *os.File) io.Writer {
+ if file == nil {
+ panic("nil passed instead of *os.File to NewColorable()")
+ }
+
+ return file
+}
+
+// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout.
+func NewColorableStdout() io.Writer {
+ return os.Stdout
+}
+
+// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr.
+func NewColorableStderr() io.Writer {
+ return os.Stderr
+}
+
+// EnableColorsStdout enable colors if possible.
+func EnableColorsStdout(enabled *bool) func() {
+ if enabled != nil {
+ *enabled = true
+ }
+ return func() {}
+}
diff --git a/vendor/github.com/mattn/go-colorable/colorable_others.go b/vendor/github.com/mattn/go-colorable/colorable_others.go
new file mode 100644
index 0000000..766d946
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/colorable_others.go
@@ -0,0 +1,38 @@
+//go:build !windows && !appengine
+// +build !windows,!appengine
+
+package colorable
+
+import (
+ "io"
+ "os"
+
+ _ "github.com/mattn/go-isatty"
+)
+
+// NewColorable returns new instance of Writer which handles escape sequence.
+func NewColorable(file *os.File) io.Writer {
+ if file == nil {
+ panic("nil passed instead of *os.File to NewColorable()")
+ }
+
+ return file
+}
+
+// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout.
+func NewColorableStdout() io.Writer {
+ return os.Stdout
+}
+
+// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr.
+func NewColorableStderr() io.Writer {
+ return os.Stderr
+}
+
+// EnableColorsStdout enable colors if possible.
+func EnableColorsStdout(enabled *bool) func() {
+ if enabled != nil {
+ *enabled = true
+ }
+ return func() {}
+}
diff --git a/vendor/github.com/mattn/go-colorable/colorable_windows.go b/vendor/github.com/mattn/go-colorable/colorable_windows.go
new file mode 100644
index 0000000..1846ad5
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/colorable_windows.go
@@ -0,0 +1,1047 @@
+//go:build windows && !appengine
+// +build windows,!appengine
+
+package colorable
+
+import (
+ "bytes"
+ "io"
+ "math"
+ "os"
+ "strconv"
+ "strings"
+ "sync"
+ "syscall"
+ "unsafe"
+
+ "github.com/mattn/go-isatty"
+)
+
+const (
+ foregroundBlue = 0x1
+ foregroundGreen = 0x2
+ foregroundRed = 0x4
+ foregroundIntensity = 0x8
+ foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity)
+ backgroundBlue = 0x10
+ backgroundGreen = 0x20
+ backgroundRed = 0x40
+ backgroundIntensity = 0x80
+ backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
+ commonLvbUnderscore = 0x8000
+
+ cENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
+)
+
+const (
+ genericRead = 0x80000000
+ genericWrite = 0x40000000
+)
+
+const (
+ consoleTextmodeBuffer = 0x1
+)
+
+type wchar uint16
+type short int16
+type dword uint32
+type word uint16
+
+type coord struct {
+ x short
+ y short
+}
+
+type smallRect struct {
+ left short
+ top short
+ right short
+ bottom short
+}
+
+type consoleScreenBufferInfo struct {
+ size coord
+ cursorPosition coord
+ attributes word
+ window smallRect
+ maximumWindowSize coord
+}
+
+type consoleCursorInfo struct {
+ size dword
+ visible int32
+}
+
+var (
+ kernel32 = syscall.NewLazyDLL("kernel32.dll")
+ procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
+ procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
+ procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
+ procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
+ procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute")
+ procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo")
+ procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo")
+ procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW")
+ procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
+ procSetConsoleMode = kernel32.NewProc("SetConsoleMode")
+ procCreateConsoleScreenBuffer = kernel32.NewProc("CreateConsoleScreenBuffer")
+)
+
+// Writer provides colorable Writer to the console
+type Writer struct {
+ out io.Writer
+ handle syscall.Handle
+ althandle syscall.Handle
+ oldattr word
+ oldpos coord
+ rest bytes.Buffer
+ mutex sync.Mutex
+}
+
+// NewColorable returns new instance of Writer which handles escape sequence from File.
+func NewColorable(file *os.File) io.Writer {
+ if file == nil {
+ panic("nil passed instead of *os.File to NewColorable()")
+ }
+
+ if isatty.IsTerminal(file.Fd()) {
+ var mode uint32
+ if r, _, _ := procGetConsoleMode.Call(file.Fd(), uintptr(unsafe.Pointer(&mode))); r != 0 && mode&cENABLE_VIRTUAL_TERMINAL_PROCESSING != 0 {
+ return file
+ }
+ var csbi consoleScreenBufferInfo
+ handle := syscall.Handle(file.Fd())
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}}
+ }
+ return file
+}
+
+// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout.
+func NewColorableStdout() io.Writer {
+ return NewColorable(os.Stdout)
+}
+
+// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr.
+func NewColorableStderr() io.Writer {
+ return NewColorable(os.Stderr)
+}
+
+var color256 = map[int]int{
+ 0: 0x000000,
+ 1: 0x800000,
+ 2: 0x008000,
+ 3: 0x808000,
+ 4: 0x000080,
+ 5: 0x800080,
+ 6: 0x008080,
+ 7: 0xc0c0c0,
+ 8: 0x808080,
+ 9: 0xff0000,
+ 10: 0x00ff00,
+ 11: 0xffff00,
+ 12: 0x0000ff,
+ 13: 0xff00ff,
+ 14: 0x00ffff,
+ 15: 0xffffff,
+ 16: 0x000000,
+ 17: 0x00005f,
+ 18: 0x000087,
+ 19: 0x0000af,
+ 20: 0x0000d7,
+ 21: 0x0000ff,
+ 22: 0x005f00,
+ 23: 0x005f5f,
+ 24: 0x005f87,
+ 25: 0x005faf,
+ 26: 0x005fd7,
+ 27: 0x005fff,
+ 28: 0x008700,
+ 29: 0x00875f,
+ 30: 0x008787,
+ 31: 0x0087af,
+ 32: 0x0087d7,
+ 33: 0x0087ff,
+ 34: 0x00af00,
+ 35: 0x00af5f,
+ 36: 0x00af87,
+ 37: 0x00afaf,
+ 38: 0x00afd7,
+ 39: 0x00afff,
+ 40: 0x00d700,
+ 41: 0x00d75f,
+ 42: 0x00d787,
+ 43: 0x00d7af,
+ 44: 0x00d7d7,
+ 45: 0x00d7ff,
+ 46: 0x00ff00,
+ 47: 0x00ff5f,
+ 48: 0x00ff87,
+ 49: 0x00ffaf,
+ 50: 0x00ffd7,
+ 51: 0x00ffff,
+ 52: 0x5f0000,
+ 53: 0x5f005f,
+ 54: 0x5f0087,
+ 55: 0x5f00af,
+ 56: 0x5f00d7,
+ 57: 0x5f00ff,
+ 58: 0x5f5f00,
+ 59: 0x5f5f5f,
+ 60: 0x5f5f87,
+ 61: 0x5f5faf,
+ 62: 0x5f5fd7,
+ 63: 0x5f5fff,
+ 64: 0x5f8700,
+ 65: 0x5f875f,
+ 66: 0x5f8787,
+ 67: 0x5f87af,
+ 68: 0x5f87d7,
+ 69: 0x5f87ff,
+ 70: 0x5faf00,
+ 71: 0x5faf5f,
+ 72: 0x5faf87,
+ 73: 0x5fafaf,
+ 74: 0x5fafd7,
+ 75: 0x5fafff,
+ 76: 0x5fd700,
+ 77: 0x5fd75f,
+ 78: 0x5fd787,
+ 79: 0x5fd7af,
+ 80: 0x5fd7d7,
+ 81: 0x5fd7ff,
+ 82: 0x5fff00,
+ 83: 0x5fff5f,
+ 84: 0x5fff87,
+ 85: 0x5fffaf,
+ 86: 0x5fffd7,
+ 87: 0x5fffff,
+ 88: 0x870000,
+ 89: 0x87005f,
+ 90: 0x870087,
+ 91: 0x8700af,
+ 92: 0x8700d7,
+ 93: 0x8700ff,
+ 94: 0x875f00,
+ 95: 0x875f5f,
+ 96: 0x875f87,
+ 97: 0x875faf,
+ 98: 0x875fd7,
+ 99: 0x875fff,
+ 100: 0x878700,
+ 101: 0x87875f,
+ 102: 0x878787,
+ 103: 0x8787af,
+ 104: 0x8787d7,
+ 105: 0x8787ff,
+ 106: 0x87af00,
+ 107: 0x87af5f,
+ 108: 0x87af87,
+ 109: 0x87afaf,
+ 110: 0x87afd7,
+ 111: 0x87afff,
+ 112: 0x87d700,
+ 113: 0x87d75f,
+ 114: 0x87d787,
+ 115: 0x87d7af,
+ 116: 0x87d7d7,
+ 117: 0x87d7ff,
+ 118: 0x87ff00,
+ 119: 0x87ff5f,
+ 120: 0x87ff87,
+ 121: 0x87ffaf,
+ 122: 0x87ffd7,
+ 123: 0x87ffff,
+ 124: 0xaf0000,
+ 125: 0xaf005f,
+ 126: 0xaf0087,
+ 127: 0xaf00af,
+ 128: 0xaf00d7,
+ 129: 0xaf00ff,
+ 130: 0xaf5f00,
+ 131: 0xaf5f5f,
+ 132: 0xaf5f87,
+ 133: 0xaf5faf,
+ 134: 0xaf5fd7,
+ 135: 0xaf5fff,
+ 136: 0xaf8700,
+ 137: 0xaf875f,
+ 138: 0xaf8787,
+ 139: 0xaf87af,
+ 140: 0xaf87d7,
+ 141: 0xaf87ff,
+ 142: 0xafaf00,
+ 143: 0xafaf5f,
+ 144: 0xafaf87,
+ 145: 0xafafaf,
+ 146: 0xafafd7,
+ 147: 0xafafff,
+ 148: 0xafd700,
+ 149: 0xafd75f,
+ 150: 0xafd787,
+ 151: 0xafd7af,
+ 152: 0xafd7d7,
+ 153: 0xafd7ff,
+ 154: 0xafff00,
+ 155: 0xafff5f,
+ 156: 0xafff87,
+ 157: 0xafffaf,
+ 158: 0xafffd7,
+ 159: 0xafffff,
+ 160: 0xd70000,
+ 161: 0xd7005f,
+ 162: 0xd70087,
+ 163: 0xd700af,
+ 164: 0xd700d7,
+ 165: 0xd700ff,
+ 166: 0xd75f00,
+ 167: 0xd75f5f,
+ 168: 0xd75f87,
+ 169: 0xd75faf,
+ 170: 0xd75fd7,
+ 171: 0xd75fff,
+ 172: 0xd78700,
+ 173: 0xd7875f,
+ 174: 0xd78787,
+ 175: 0xd787af,
+ 176: 0xd787d7,
+ 177: 0xd787ff,
+ 178: 0xd7af00,
+ 179: 0xd7af5f,
+ 180: 0xd7af87,
+ 181: 0xd7afaf,
+ 182: 0xd7afd7,
+ 183: 0xd7afff,
+ 184: 0xd7d700,
+ 185: 0xd7d75f,
+ 186: 0xd7d787,
+ 187: 0xd7d7af,
+ 188: 0xd7d7d7,
+ 189: 0xd7d7ff,
+ 190: 0xd7ff00,
+ 191: 0xd7ff5f,
+ 192: 0xd7ff87,
+ 193: 0xd7ffaf,
+ 194: 0xd7ffd7,
+ 195: 0xd7ffff,
+ 196: 0xff0000,
+ 197: 0xff005f,
+ 198: 0xff0087,
+ 199: 0xff00af,
+ 200: 0xff00d7,
+ 201: 0xff00ff,
+ 202: 0xff5f00,
+ 203: 0xff5f5f,
+ 204: 0xff5f87,
+ 205: 0xff5faf,
+ 206: 0xff5fd7,
+ 207: 0xff5fff,
+ 208: 0xff8700,
+ 209: 0xff875f,
+ 210: 0xff8787,
+ 211: 0xff87af,
+ 212: 0xff87d7,
+ 213: 0xff87ff,
+ 214: 0xffaf00,
+ 215: 0xffaf5f,
+ 216: 0xffaf87,
+ 217: 0xffafaf,
+ 218: 0xffafd7,
+ 219: 0xffafff,
+ 220: 0xffd700,
+ 221: 0xffd75f,
+ 222: 0xffd787,
+ 223: 0xffd7af,
+ 224: 0xffd7d7,
+ 225: 0xffd7ff,
+ 226: 0xffff00,
+ 227: 0xffff5f,
+ 228: 0xffff87,
+ 229: 0xffffaf,
+ 230: 0xffffd7,
+ 231: 0xffffff,
+ 232: 0x080808,
+ 233: 0x121212,
+ 234: 0x1c1c1c,
+ 235: 0x262626,
+ 236: 0x303030,
+ 237: 0x3a3a3a,
+ 238: 0x444444,
+ 239: 0x4e4e4e,
+ 240: 0x585858,
+ 241: 0x626262,
+ 242: 0x6c6c6c,
+ 243: 0x767676,
+ 244: 0x808080,
+ 245: 0x8a8a8a,
+ 246: 0x949494,
+ 247: 0x9e9e9e,
+ 248: 0xa8a8a8,
+ 249: 0xb2b2b2,
+ 250: 0xbcbcbc,
+ 251: 0xc6c6c6,
+ 252: 0xd0d0d0,
+ 253: 0xdadada,
+ 254: 0xe4e4e4,
+ 255: 0xeeeeee,
+}
+
+// `\033]0;TITLESTR\007`
+func doTitleSequence(er *bytes.Reader) error {
+ var c byte
+ var err error
+
+ c, err = er.ReadByte()
+ if err != nil {
+ return err
+ }
+ if c != '0' && c != '2' {
+ return nil
+ }
+ c, err = er.ReadByte()
+ if err != nil {
+ return err
+ }
+ if c != ';' {
+ return nil
+ }
+ title := make([]byte, 0, 80)
+ for {
+ c, err = er.ReadByte()
+ if err != nil {
+ return err
+ }
+ if c == 0x07 || c == '\n' {
+ break
+ }
+ title = append(title, c)
+ }
+ if len(title) > 0 {
+ title8, err := syscall.UTF16PtrFromString(string(title))
+ if err == nil {
+ procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8)))
+ }
+ }
+ return nil
+}
+
+// returns Atoi(s) unless s == "" in which case it returns def
+func atoiWithDefault(s string, def int) (int, error) {
+ if s == "" {
+ return def, nil
+ }
+ return strconv.Atoi(s)
+}
+
+// Write writes data on console
+func (w *Writer) Write(data []byte) (n int, err error) {
+ w.mutex.Lock()
+ defer w.mutex.Unlock()
+ var csbi consoleScreenBufferInfo
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+
+ handle := w.handle
+
+ var er *bytes.Reader
+ if w.rest.Len() > 0 {
+ var rest bytes.Buffer
+ w.rest.WriteTo(&rest)
+ w.rest.Reset()
+ rest.Write(data)
+ er = bytes.NewReader(rest.Bytes())
+ } else {
+ er = bytes.NewReader(data)
+ }
+ var plaintext bytes.Buffer
+loop:
+ for {
+ c1, err := er.ReadByte()
+ if err != nil {
+ plaintext.WriteTo(w.out)
+ break loop
+ }
+ if c1 != 0x1b {
+ plaintext.WriteByte(c1)
+ continue
+ }
+ _, err = plaintext.WriteTo(w.out)
+ if err != nil {
+ break loop
+ }
+ c2, err := er.ReadByte()
+ if err != nil {
+ break loop
+ }
+
+ switch c2 {
+ case '>':
+ continue
+ case ']':
+ w.rest.WriteByte(c1)
+ w.rest.WriteByte(c2)
+ er.WriteTo(&w.rest)
+ if bytes.IndexByte(w.rest.Bytes(), 0x07) == -1 {
+ break loop
+ }
+ er = bytes.NewReader(w.rest.Bytes()[2:])
+ err := doTitleSequence(er)
+ if err != nil {
+ break loop
+ }
+ w.rest.Reset()
+ continue
+ // https://github.com/mattn/go-colorable/issues/27
+ case '7':
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ w.oldpos = csbi.cursorPosition
+ continue
+ case '8':
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&w.oldpos)))
+ continue
+ case 0x5b:
+ // execute part after switch
+ default:
+ continue
+ }
+
+ w.rest.WriteByte(c1)
+ w.rest.WriteByte(c2)
+ er.WriteTo(&w.rest)
+
+ var buf bytes.Buffer
+ var m byte
+ for i, c := range w.rest.Bytes()[2:] {
+ if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
+ m = c
+ er = bytes.NewReader(w.rest.Bytes()[2+i+1:])
+ w.rest.Reset()
+ break
+ }
+ buf.Write([]byte(string(c)))
+ }
+ if m == 0 {
+ break loop
+ }
+
+ switch m {
+ case 'A':
+ n, err = atoiWithDefault(buf.String(), 1)
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.y -= short(n)
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'B':
+ n, err = atoiWithDefault(buf.String(), 1)
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.y += short(n)
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'C':
+ n, err = atoiWithDefault(buf.String(), 1)
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x += short(n)
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'D':
+ n, err = atoiWithDefault(buf.String(), 1)
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x -= short(n)
+ if csbi.cursorPosition.x < 0 {
+ csbi.cursorPosition.x = 0
+ }
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'E':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x = 0
+ csbi.cursorPosition.y += short(n)
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'F':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x = 0
+ csbi.cursorPosition.y -= short(n)
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'G':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ if n < 1 {
+ n = 1
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x = short(n - 1)
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'H', 'f':
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ if buf.Len() > 0 {
+ token := strings.Split(buf.String(), ";")
+ switch len(token) {
+ case 1:
+ n1, err := strconv.Atoi(token[0])
+ if err != nil {
+ continue
+ }
+ csbi.cursorPosition.y = short(n1 - 1)
+ case 2:
+ n1, err := strconv.Atoi(token[0])
+ if err != nil {
+ continue
+ }
+ n2, err := strconv.Atoi(token[1])
+ if err != nil {
+ continue
+ }
+ csbi.cursorPosition.x = short(n2 - 1)
+ csbi.cursorPosition.y = short(n1 - 1)
+ }
+ } else {
+ csbi.cursorPosition.y = 0
+ }
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'J':
+ n := 0
+ if buf.Len() > 0 {
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ }
+ var count, written dword
+ var cursor coord
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ switch n {
+ case 0:
+ cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
+ count = dword(csbi.size.x) - dword(csbi.cursorPosition.x) + dword(csbi.size.y-csbi.cursorPosition.y)*dword(csbi.size.x)
+ case 1:
+ cursor = coord{x: csbi.window.left, y: csbi.window.top}
+ count = dword(csbi.size.x) - dword(csbi.cursorPosition.x) + dword(csbi.window.top-csbi.cursorPosition.y)*dword(csbi.size.x)
+ case 2:
+ cursor = coord{x: csbi.window.left, y: csbi.window.top}
+ count = dword(csbi.size.x) - dword(csbi.cursorPosition.x) + dword(csbi.size.y-csbi.cursorPosition.y)*dword(csbi.size.x)
+ }
+ procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ case 'K':
+ n := 0
+ if buf.Len() > 0 {
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ var cursor coord
+ var count, written dword
+ switch n {
+ case 0:
+ cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
+ count = dword(csbi.size.x - csbi.cursorPosition.x)
+ case 1:
+ cursor = coord{x: csbi.window.left, y: csbi.cursorPosition.y}
+ count = dword(csbi.size.x - csbi.cursorPosition.x)
+ case 2:
+ cursor = coord{x: csbi.window.left, y: csbi.cursorPosition.y}
+ count = dword(csbi.size.x)
+ }
+ procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ case 'X':
+ n := 0
+ if buf.Len() > 0 {
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ var cursor coord
+ var written dword
+ cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
+ procFillConsoleOutputCharacter.Call(uintptr(handle), uintptr(' '), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ procFillConsoleOutputAttribute.Call(uintptr(handle), uintptr(csbi.attributes), uintptr(n), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ case 'm':
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ attr := csbi.attributes
+ cs := buf.String()
+ if cs == "" {
+ procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(w.oldattr))
+ continue
+ }
+ token := strings.Split(cs, ";")
+ for i := 0; i < len(token); i++ {
+ ns := token[i]
+ if n, err = strconv.Atoi(ns); err == nil {
+ switch {
+ case n == 0 || n == 100:
+ attr = w.oldattr
+ case n == 4:
+ attr |= commonLvbUnderscore
+ case (1 <= n && n <= 3) || n == 5:
+ attr |= foregroundIntensity
+ case n == 7 || n == 27:
+ attr =
+ (attr &^ (foregroundMask | backgroundMask)) |
+ ((attr & foregroundMask) << 4) |
+ ((attr & backgroundMask) >> 4)
+ case n == 22:
+ attr &^= foregroundIntensity
+ case n == 24:
+ attr &^= commonLvbUnderscore
+ case 30 <= n && n <= 37:
+ attr &= backgroundMask
+ if (n-30)&1 != 0 {
+ attr |= foregroundRed
+ }
+ if (n-30)&2 != 0 {
+ attr |= foregroundGreen
+ }
+ if (n-30)&4 != 0 {
+ attr |= foregroundBlue
+ }
+ case n == 38: // set foreground color.
+ if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") {
+ if n256, err := strconv.Atoi(token[i+2]); err == nil {
+ if n256foreAttr == nil {
+ n256setup()
+ }
+ attr &= backgroundMask
+ attr |= n256foreAttr[n256%len(n256foreAttr)]
+ i += 2
+ }
+ } else if len(token) == 5 && token[i+1] == "2" {
+ var r, g, b int
+ r, _ = strconv.Atoi(token[i+2])
+ g, _ = strconv.Atoi(token[i+3])
+ b, _ = strconv.Atoi(token[i+4])
+ i += 4
+ if r > 127 {
+ attr |= foregroundRed
+ }
+ if g > 127 {
+ attr |= foregroundGreen
+ }
+ if b > 127 {
+ attr |= foregroundBlue
+ }
+ } else {
+ attr = attr & (w.oldattr & backgroundMask)
+ }
+ case n == 39: // reset foreground color.
+ attr &= backgroundMask
+ attr |= w.oldattr & foregroundMask
+ case 40 <= n && n <= 47:
+ attr &= foregroundMask
+ if (n-40)&1 != 0 {
+ attr |= backgroundRed
+ }
+ if (n-40)&2 != 0 {
+ attr |= backgroundGreen
+ }
+ if (n-40)&4 != 0 {
+ attr |= backgroundBlue
+ }
+ case n == 48: // set background color.
+ if i < len(token)-2 && token[i+1] == "5" {
+ if n256, err := strconv.Atoi(token[i+2]); err == nil {
+ if n256backAttr == nil {
+ n256setup()
+ }
+ attr &= foregroundMask
+ attr |= n256backAttr[n256%len(n256backAttr)]
+ i += 2
+ }
+ } else if len(token) == 5 && token[i+1] == "2" {
+ var r, g, b int
+ r, _ = strconv.Atoi(token[i+2])
+ g, _ = strconv.Atoi(token[i+3])
+ b, _ = strconv.Atoi(token[i+4])
+ i += 4
+ if r > 127 {
+ attr |= backgroundRed
+ }
+ if g > 127 {
+ attr |= backgroundGreen
+ }
+ if b > 127 {
+ attr |= backgroundBlue
+ }
+ } else {
+ attr = attr & (w.oldattr & foregroundMask)
+ }
+ case n == 49: // reset foreground color.
+ attr &= foregroundMask
+ attr |= w.oldattr & backgroundMask
+ case 90 <= n && n <= 97:
+ attr = (attr & backgroundMask)
+ attr |= foregroundIntensity
+ if (n-90)&1 != 0 {
+ attr |= foregroundRed
+ }
+ if (n-90)&2 != 0 {
+ attr |= foregroundGreen
+ }
+ if (n-90)&4 != 0 {
+ attr |= foregroundBlue
+ }
+ case 100 <= n && n <= 107:
+ attr = (attr & foregroundMask)
+ attr |= backgroundIntensity
+ if (n-100)&1 != 0 {
+ attr |= backgroundRed
+ }
+ if (n-100)&2 != 0 {
+ attr |= backgroundGreen
+ }
+ if (n-100)&4 != 0 {
+ attr |= backgroundBlue
+ }
+ }
+ procSetConsoleTextAttribute.Call(uintptr(handle), uintptr(attr))
+ }
+ }
+ case 'h':
+ var ci consoleCursorInfo
+ cs := buf.String()
+ if cs == "5>" {
+ procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ ci.visible = 0
+ procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ } else if cs == "?25" {
+ procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ ci.visible = 1
+ procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ } else if cs == "?1049" {
+ if w.althandle == 0 {
+ h, _, _ := procCreateConsoleScreenBuffer.Call(uintptr(genericRead|genericWrite), 0, 0, uintptr(consoleTextmodeBuffer), 0, 0)
+ w.althandle = syscall.Handle(h)
+ if w.althandle != 0 {
+ handle = w.althandle
+ }
+ }
+ }
+ case 'l':
+ var ci consoleCursorInfo
+ cs := buf.String()
+ if cs == "5>" {
+ procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ ci.visible = 1
+ procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ } else if cs == "?25" {
+ procGetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ ci.visible = 0
+ procSetConsoleCursorInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&ci)))
+ } else if cs == "?1049" {
+ if w.althandle != 0 {
+ syscall.CloseHandle(w.althandle)
+ w.althandle = 0
+ handle = w.handle
+ }
+ }
+ case 's':
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ w.oldpos = csbi.cursorPosition
+ case 'u':
+ procSetConsoleCursorPosition.Call(uintptr(handle), *(*uintptr)(unsafe.Pointer(&w.oldpos)))
+ }
+ }
+
+ return len(data), nil
+}
+
+type consoleColor struct {
+ rgb int
+ red bool
+ green bool
+ blue bool
+ intensity bool
+}
+
+func (c consoleColor) foregroundAttr() (attr word) {
+ if c.red {
+ attr |= foregroundRed
+ }
+ if c.green {
+ attr |= foregroundGreen
+ }
+ if c.blue {
+ attr |= foregroundBlue
+ }
+ if c.intensity {
+ attr |= foregroundIntensity
+ }
+ return
+}
+
+func (c consoleColor) backgroundAttr() (attr word) {
+ if c.red {
+ attr |= backgroundRed
+ }
+ if c.green {
+ attr |= backgroundGreen
+ }
+ if c.blue {
+ attr |= backgroundBlue
+ }
+ if c.intensity {
+ attr |= backgroundIntensity
+ }
+ return
+}
+
+var color16 = []consoleColor{
+ {0x000000, false, false, false, false},
+ {0x000080, false, false, true, false},
+ {0x008000, false, true, false, false},
+ {0x008080, false, true, true, false},
+ {0x800000, true, false, false, false},
+ {0x800080, true, false, true, false},
+ {0x808000, true, true, false, false},
+ {0xc0c0c0, true, true, true, false},
+ {0x808080, false, false, false, true},
+ {0x0000ff, false, false, true, true},
+ {0x00ff00, false, true, false, true},
+ {0x00ffff, false, true, true, true},
+ {0xff0000, true, false, false, true},
+ {0xff00ff, true, false, true, true},
+ {0xffff00, true, true, false, true},
+ {0xffffff, true, true, true, true},
+}
+
+type hsv struct {
+ h, s, v float32
+}
+
+func (a hsv) dist(b hsv) float32 {
+ dh := a.h - b.h
+ switch {
+ case dh > 0.5:
+ dh = 1 - dh
+ case dh < -0.5:
+ dh = -1 - dh
+ }
+ ds := a.s - b.s
+ dv := a.v - b.v
+ return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv)))
+}
+
+func toHSV(rgb int) hsv {
+ r, g, b := float32((rgb&0xFF0000)>>16)/256.0,
+ float32((rgb&0x00FF00)>>8)/256.0,
+ float32(rgb&0x0000FF)/256.0
+ min, max := minmax3f(r, g, b)
+ h := max - min
+ if h > 0 {
+ if max == r {
+ h = (g - b) / h
+ if h < 0 {
+ h += 6
+ }
+ } else if max == g {
+ h = 2 + (b-r)/h
+ } else {
+ h = 4 + (r-g)/h
+ }
+ }
+ h /= 6.0
+ s := max - min
+ if max != 0 {
+ s /= max
+ }
+ v := max
+ return hsv{h: h, s: s, v: v}
+}
+
+type hsvTable []hsv
+
+func toHSVTable(rgbTable []consoleColor) hsvTable {
+ t := make(hsvTable, len(rgbTable))
+ for i, c := range rgbTable {
+ t[i] = toHSV(c.rgb)
+ }
+ return t
+}
+
+func (t hsvTable) find(rgb int) consoleColor {
+ hsv := toHSV(rgb)
+ n := 7
+ l := float32(5.0)
+ for i, p := range t {
+ d := hsv.dist(p)
+ if d < l {
+ l, n = d, i
+ }
+ }
+ return color16[n]
+}
+
+func minmax3f(a, b, c float32) (min, max float32) {
+ if a < b {
+ if b < c {
+ return a, c
+ } else if a < c {
+ return a, b
+ } else {
+ return c, b
+ }
+ } else {
+ if a < c {
+ return b, c
+ } else if b < c {
+ return b, a
+ } else {
+ return c, a
+ }
+ }
+}
+
+var n256foreAttr []word
+var n256backAttr []word
+
+func n256setup() {
+ n256foreAttr = make([]word, 256)
+ n256backAttr = make([]word, 256)
+ t := toHSVTable(color16)
+ for i, rgb := range color256 {
+ c := t.find(rgb)
+ n256foreAttr[i] = c.foregroundAttr()
+ n256backAttr[i] = c.backgroundAttr()
+ }
+}
+
+// EnableColorsStdout enable colors if possible.
+func EnableColorsStdout(enabled *bool) func() {
+ var mode uint32
+ h := os.Stdout.Fd()
+ if r, _, _ := procGetConsoleMode.Call(h, uintptr(unsafe.Pointer(&mode))); r != 0 {
+ if r, _, _ = procSetConsoleMode.Call(h, uintptr(mode|cENABLE_VIRTUAL_TERMINAL_PROCESSING)); r != 0 {
+ if enabled != nil {
+ *enabled = true
+ }
+ return func() {
+ procSetConsoleMode.Call(h, uintptr(mode))
+ }
+ }
+ }
+ if enabled != nil {
+ *enabled = true
+ }
+ return func() {}
+}
diff --git a/vendor/github.com/mattn/go-colorable/go.mod b/vendor/github.com/mattn/go-colorable/go.mod
new file mode 100644
index 0000000..27351c0
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/go.mod
@@ -0,0 +1,8 @@
+module github.com/mattn/go-colorable
+
+require (
+ github.com/mattn/go-isatty v0.0.14
+ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
+)
+
+go 1.13
diff --git a/vendor/github.com/mattn/go-colorable/go.sum b/vendor/github.com/mattn/go-colorable/go.sum
new file mode 100644
index 0000000..40c33b3
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/go.sum
@@ -0,0 +1,5 @@
+github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
+github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo=
+golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/vendor/github.com/mattn/go-colorable/go.test.sh b/vendor/github.com/mattn/go-colorable/go.test.sh
new file mode 100644
index 0000000..012162b
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/go.test.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -e
+echo "" > coverage.txt
+
+for d in $(go list ./... | grep -v vendor); do
+ go test -race -coverprofile=profile.out -covermode=atomic "$d"
+ if [ -f profile.out ]; then
+ cat profile.out >> coverage.txt
+ rm profile.out
+ fi
+done
diff --git a/vendor/github.com/mattn/go-colorable/noncolorable.go b/vendor/github.com/mattn/go-colorable/noncolorable.go
new file mode 100644
index 0000000..05d6f74
--- /dev/null
+++ b/vendor/github.com/mattn/go-colorable/noncolorable.go
@@ -0,0 +1,57 @@
+package colorable
+
+import (
+ "bytes"
+ "io"
+)
+
+// NonColorable holds writer but removes escape sequence.
+type NonColorable struct {
+ out io.Writer
+}
+
+// NewNonColorable returns new instance of Writer which removes escape sequence from Writer.
+func NewNonColorable(w io.Writer) io.Writer {
+ return &NonColorable{out: w}
+}
+
+// Write writes data on console
+func (w *NonColorable) Write(data []byte) (n int, err error) {
+ er := bytes.NewReader(data)
+ var plaintext bytes.Buffer
+loop:
+ for {
+ c1, err := er.ReadByte()
+ if err != nil {
+ plaintext.WriteTo(w.out)
+ break loop
+ }
+ if c1 != 0x1b {
+ plaintext.WriteByte(c1)
+ continue
+ }
+ _, err = plaintext.WriteTo(w.out)
+ if err != nil {
+ break loop
+ }
+ c2, err := er.ReadByte()
+ if err != nil {
+ break loop
+ }
+ if c2 != 0x5b {
+ continue
+ }
+
+ for {
+ c, err := er.ReadByte()
+ if err != nil {
+ break loop
+ }
+ if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
+ break
+ }
+ }
+ }
+
+ return len(data), nil
+}
diff --git a/vendor/github.com/mattn/go-isatty/LICENSE b/vendor/github.com/mattn/go-isatty/LICENSE
new file mode 100644
index 0000000..65dc692
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/LICENSE
@@ -0,0 +1,9 @@
+Copyright (c) Yasuhiro MATSUMOTO
+
+MIT License (Expat)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/mattn/go-isatty/README.md b/vendor/github.com/mattn/go-isatty/README.md
new file mode 100644
index 0000000..3841835
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/README.md
@@ -0,0 +1,50 @@
+# go-isatty
+
+[![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty)
+[![Codecov](https://codecov.io/gh/mattn/go-isatty/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-isatty)
+[![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master)
+[![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty)
+
+isatty for golang
+
+## Usage
+
+```go
+package main
+
+import (
+ "fmt"
+ "github.com/mattn/go-isatty"
+ "os"
+)
+
+func main() {
+ if isatty.IsTerminal(os.Stdout.Fd()) {
+ fmt.Println("Is Terminal")
+ } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
+ fmt.Println("Is Cygwin/MSYS2 Terminal")
+ } else {
+ fmt.Println("Is Not Terminal")
+ }
+}
+```
+
+## Installation
+
+```
+$ go get github.com/mattn/go-isatty
+```
+
+## License
+
+MIT
+
+## Author
+
+Yasuhiro Matsumoto (a.k.a mattn)
+
+## Thanks
+
+* k-takata: base idea for IsCygwinTerminal
+
+ https://github.com/k-takata/go-iscygpty
diff --git a/vendor/github.com/mattn/go-isatty/doc.go b/vendor/github.com/mattn/go-isatty/doc.go
new file mode 100644
index 0000000..17d4f90
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/doc.go
@@ -0,0 +1,2 @@
+// Package isatty implements interface to isatty
+package isatty
diff --git a/vendor/github.com/mattn/go-isatty/go.mod b/vendor/github.com/mattn/go-isatty/go.mod
new file mode 100644
index 0000000..c9a20b7
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/go.mod
@@ -0,0 +1,5 @@
+module github.com/mattn/go-isatty
+
+go 1.12
+
+require golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
diff --git a/vendor/github.com/mattn/go-isatty/go.sum b/vendor/github.com/mattn/go-isatty/go.sum
new file mode 100644
index 0000000..912e29c
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/go.sum
@@ -0,0 +1,2 @@
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/vendor/github.com/mattn/go-isatty/go.test.sh b/vendor/github.com/mattn/go-isatty/go.test.sh
new file mode 100644
index 0000000..012162b
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/go.test.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -e
+echo "" > coverage.txt
+
+for d in $(go list ./... | grep -v vendor); do
+ go test -race -coverprofile=profile.out -covermode=atomic "$d"
+ if [ -f profile.out ]; then
+ cat profile.out >> coverage.txt
+ rm profile.out
+ fi
+done
diff --git a/vendor/github.com/mattn/go-isatty/isatty_bsd.go b/vendor/github.com/mattn/go-isatty/isatty_bsd.go
new file mode 100644
index 0000000..39bbcf0
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/isatty_bsd.go
@@ -0,0 +1,19 @@
+//go:build (darwin || freebsd || openbsd || netbsd || dragonfly) && !appengine
+// +build darwin freebsd openbsd netbsd dragonfly
+// +build !appengine
+
+package isatty
+
+import "golang.org/x/sys/unix"
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
+ return err == nil
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_others.go b/vendor/github.com/mattn/go-isatty/isatty_others.go
new file mode 100644
index 0000000..3150322
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/isatty_others.go
@@ -0,0 +1,16 @@
+//go:build appengine || js || nacl || wasm
+// +build appengine js nacl wasm
+
+package isatty
+
+// IsTerminal returns true if the file descriptor is terminal which
+// is always false on js and appengine classic which is a sandboxed PaaS.
+func IsTerminal(fd uintptr) bool {
+ return false
+}
+
+// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_plan9.go b/vendor/github.com/mattn/go-isatty/isatty_plan9.go
new file mode 100644
index 0000000..bae7f9b
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/isatty_plan9.go
@@ -0,0 +1,23 @@
+//go:build plan9
+// +build plan9
+
+package isatty
+
+import (
+ "syscall"
+)
+
+// IsTerminal returns true if the given file descriptor is a terminal.
+func IsTerminal(fd uintptr) bool {
+ path, err := syscall.Fd2path(int(fd))
+ if err != nil {
+ return false
+ }
+ return path == "/dev/cons" || path == "/mnt/term/dev/cons"
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_solaris.go b/vendor/github.com/mattn/go-isatty/isatty_solaris.go
new file mode 100644
index 0000000..0c3acf2
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/isatty_solaris.go
@@ -0,0 +1,21 @@
+//go:build solaris && !appengine
+// +build solaris,!appengine
+
+package isatty
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+// IsTerminal returns true if the given file descriptor is a terminal.
+// see: https://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/isatty.c
+func IsTerminal(fd uintptr) bool {
+ _, err := unix.IoctlGetTermio(int(fd), unix.TCGETA)
+ return err == nil
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_tcgets.go b/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
new file mode 100644
index 0000000..6778765
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
@@ -0,0 +1,19 @@
+//go:build (linux || aix || zos) && !appengine
+// +build linux aix zos
+// +build !appengine
+
+package isatty
+
+import "golang.org/x/sys/unix"
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
+ return err == nil
+}
+
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
+// terminal. This is also always false on this environment.
+func IsCygwinTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_windows.go b/vendor/github.com/mattn/go-isatty/isatty_windows.go
new file mode 100644
index 0000000..8e3c991
--- /dev/null
+++ b/vendor/github.com/mattn/go-isatty/isatty_windows.go
@@ -0,0 +1,125 @@
+//go:build windows && !appengine
+// +build windows,!appengine
+
+package isatty
+
+import (
+ "errors"
+ "strings"
+ "syscall"
+ "unicode/utf16"
+ "unsafe"
+)
+
+const (
+ objectNameInfo uintptr = 1
+ fileNameInfo = 2
+ fileTypePipe = 3
+)
+
+var (
+ kernel32 = syscall.NewLazyDLL("kernel32.dll")
+ ntdll = syscall.NewLazyDLL("ntdll.dll")
+ procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
+ procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
+ procGetFileType = kernel32.NewProc("GetFileType")
+ procNtQueryObject = ntdll.NewProc("NtQueryObject")
+)
+
+func init() {
+ // Check if GetFileInformationByHandleEx is available.
+ if procGetFileInformationByHandleEx.Find() != nil {
+ procGetFileInformationByHandleEx = nil
+ }
+}
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ var st uint32
+ r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
+ return r != 0 && e == 0
+}
+
+// Check pipe name is used for cygwin/msys2 pty.
+// Cygwin/MSYS2 PTY has a name like:
+// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
+func isCygwinPipeName(name string) bool {
+ token := strings.Split(name, "-")
+ if len(token) < 5 {
+ return false
+ }
+
+ if token[0] != `\msys` &&
+ token[0] != `\cygwin` &&
+ token[0] != `\Device\NamedPipe\msys` &&
+ token[0] != `\Device\NamedPipe\cygwin` {
+ return false
+ }
+
+ if token[1] == "" {
+ return false
+ }
+
+ if !strings.HasPrefix(token[2], "pty") {
+ return false
+ }
+
+ if token[3] != `from` && token[3] != `to` {
+ return false
+ }
+
+ if token[4] != "master" {
+ return false
+ }
+
+ return true
+}
+
+// getFileNameByHandle use the undocomented ntdll NtQueryObject to get file full name from file handler
+// since GetFileInformationByHandleEx is not available under windows Vista and still some old fashion
+// guys are using Windows XP, this is a workaround for those guys, it will also work on system from
+// Windows vista to 10
+// see https://stackoverflow.com/a/18792477 for details
+func getFileNameByHandle(fd uintptr) (string, error) {
+ if procNtQueryObject == nil {
+ return "", errors.New("ntdll.dll: NtQueryObject not supported")
+ }
+
+ var buf [4 + syscall.MAX_PATH]uint16
+ var result int
+ r, _, e := syscall.Syscall6(procNtQueryObject.Addr(), 5,
+ fd, objectNameInfo, uintptr(unsafe.Pointer(&buf)), uintptr(2*len(buf)), uintptr(unsafe.Pointer(&result)), 0)
+ if r != 0 {
+ return "", e
+ }
+ return string(utf16.Decode(buf[4 : 4+buf[0]/2])), nil
+}
+
+// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
+// terminal.
+func IsCygwinTerminal(fd uintptr) bool {
+ if procGetFileInformationByHandleEx == nil {
+ name, err := getFileNameByHandle(fd)
+ if err != nil {
+ return false
+ }
+ return isCygwinPipeName(name)
+ }
+
+ // Cygwin/msys's pty is a pipe.
+ ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
+ if ft != fileTypePipe || e != 0 {
+ return false
+ }
+
+ var buf [2 + syscall.MAX_PATH]uint16
+ r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
+ 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
+ uintptr(len(buf)*2), 0, 0)
+ if r == 0 || e != 0 {
+ return false
+ }
+
+ l := *(*uint32)(unsafe.Pointer(&buf))
+ return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
+}
diff --git a/vendor/golang.org/x/sys/AUTHORS b/vendor/golang.org/x/sys/AUTHORS
new file mode 100644
index 0000000..15167cd
--- /dev/null
+++ b/vendor/golang.org/x/sys/AUTHORS
@@ -0,0 +1,3 @@
+# This source code refers to The Go Authors for copyright purposes.
+# The master list of authors is in the main Go distribution,
+# visible at http://tip.golang.org/AUTHORS.
diff --git a/vendor/golang.org/x/sys/CONTRIBUTORS b/vendor/golang.org/x/sys/CONTRIBUTORS
new file mode 100644
index 0000000..1c4577e
--- /dev/null
+++ b/vendor/golang.org/x/sys/CONTRIBUTORS
@@ -0,0 +1,3 @@
+# This source code was written by the Go contributors.
+# The master list of contributors is in the main Go distribution,
+# visible at http://tip.golang.org/CONTRIBUTORS.
diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE
new file mode 100644
index 0000000..6a66aea
--- /dev/null
+++ b/vendor/golang.org/x/sys/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/golang.org/x/sys/PATENTS b/vendor/golang.org/x/sys/PATENTS
new file mode 100644
index 0000000..7330990
--- /dev/null
+++ b/vendor/golang.org/x/sys/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the Go project.
+
+Google hereby grants to You a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this section)
+patent license to make, have made, use, offer to sell, sell, import,
+transfer and otherwise run, modify and propagate the contents of this
+implementation of Go, where such license applies only to those patent
+claims, both currently owned or controlled by Google and acquired in
+the future, licensable by Google that are necessarily infringed by this
+implementation of Go. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute or
+order or agree to the institution of patent litigation against any
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that this implementation of Go or any code incorporated within this
+implementation of Go constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of Go
+shall terminate as of the date such litigation is filed.
diff --git a/vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go b/vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go
new file mode 100644
index 0000000..e07899b
--- /dev/null
+++ b/vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go
@@ -0,0 +1,30 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package unsafeheader contains header declarations for the Go runtime's
+// slice and string implementations.
+//
+// This package allows x/sys to use types equivalent to
+// reflect.SliceHeader and reflect.StringHeader without introducing
+// a dependency on the (relatively heavy) "reflect" package.
+package unsafeheader
+
+import (
+ "unsafe"
+)
+
+// Slice is the runtime representation of a slice.
+// It cannot be used safely or portably and its representation may change in a later release.
+type Slice struct {
+ Data unsafe.Pointer
+ Len int
+ Cap int
+}
+
+// String is the runtime representation of a string.
+// It cannot be used safely or portably and its representation may change in a later release.
+type String struct {
+ Data unsafe.Pointer
+ Len int
+}
diff --git a/vendor/golang.org/x/sys/unix/.gitignore b/vendor/golang.org/x/sys/unix/.gitignore
new file mode 100644
index 0000000..e3e0fc6
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/.gitignore
@@ -0,0 +1,2 @@
+_obj/
+unix.test
diff --git a/vendor/golang.org/x/sys/unix/README.md b/vendor/golang.org/x/sys/unix/README.md
new file mode 100644
index 0000000..7d3c060
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/README.md
@@ -0,0 +1,184 @@
+# Building `sys/unix`
+
+The sys/unix package provides access to the raw system call interface of the
+underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
+
+Porting Go to a new architecture/OS combination or adding syscalls, types, or
+constants to an existing architecture/OS pair requires some manual effort;
+however, there are tools that automate much of the process.
+
+## Build Systems
+
+There are currently two ways we generate the necessary files. We are currently
+migrating the build system to use containers so the builds are reproducible.
+This is being done on an OS-by-OS basis. Please update this documentation as
+components of the build system change.
+
+### Old Build System (currently for `GOOS != "linux"`)
+
+The old build system generates the Go files based on the C header files
+present on your system. This means that files
+for a given GOOS/GOARCH pair must be generated on a system with that OS and
+architecture. This also means that the generated code can differ from system
+to system, based on differences in the header files.
+
+To avoid this, if you are using the old build system, only generate the Go
+files on an installation with unmodified header files. It is also important to
+keep track of which version of the OS the files were generated from (ex.
+Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
+and have each OS upgrade correspond to a single change.
+
+To build the files for your current OS and architecture, make sure GOOS and
+GOARCH are set correctly and run `mkall.sh`. This will generate the files for
+your specific system. Running `mkall.sh -n` shows the commands that will be run.
+
+Requirements: bash, go
+
+### New Build System (currently for `GOOS == "linux"`)
+
+The new build system uses a Docker container to generate the go files directly
+from source checkouts of the kernel and various system libraries. This means
+that on any platform that supports Docker, all the files using the new build
+system can be generated at once, and generated files will not change based on
+what the person running the scripts has installed on their computer.
+
+The OS specific files for the new build system are located in the `${GOOS}`
+directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
+the kernel or system library updates, modify the Dockerfile at
+`${GOOS}/Dockerfile` to checkout the new release of the source.
+
+To build all the files under the new build system, you must be on an amd64/Linux
+system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
+then generate all of the files for all of the GOOS/GOARCH pairs in the new build
+system. Running `mkall.sh -n` shows the commands that will be run.
+
+Requirements: bash, go, docker
+
+## Component files
+
+This section describes the various files used in the code generation process.
+It also contains instructions on how to modify these files to add a new
+architecture/OS or to add additional syscalls, types, or constants. Note that
+if you are using the new build system, the scripts/programs cannot be called normally.
+They must be called from within the docker container.
+
+### asm files
+
+The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
+call dispatch. There are three entry points:
+```
+ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
+ func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
+ func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
+```
+The first and second are the standard ones; they differ only in how many
+arguments can be passed to the kernel. The third is for low-level use by the
+ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
+let it know that a system call is running.
+
+When porting Go to a new architecture/OS, this file must be implemented for
+each GOOS/GOARCH pair.
+
+### mksysnum
+
+Mksysnum is a Go program located at `${GOOS}/mksysnum.go` (or `mksysnum_${GOOS}.go`
+for the old system). This program takes in a list of header files containing the
+syscall number declarations and parses them to produce the corresponding list of
+Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
+constants.
+
+Adding new syscall numbers is mostly done by running the build on a sufficiently
+new installation of the target OS (or updating the source checkouts for the
+new build system). However, depending on the OS, you may need to update the
+parsing in mksysnum.
+
+### mksyscall.go
+
+The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
+hand-written Go files which implement system calls (for unix, the specific OS,
+or the specific OS/Architecture pair respectively) that need special handling
+and list `//sys` comments giving prototypes for ones that can be generated.
+
+The mksyscall.go program takes the `//sys` and `//sysnb` comments and converts
+them into syscalls. This requires the name of the prototype in the comment to
+match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
+prototype can be exported (capitalized) or not.
+
+Adding a new syscall often just requires adding a new `//sys` function prototype
+with the desired arguments and a capitalized name so it is exported. However, if
+you want the interface to the syscall to be different, often one will make an
+unexported `//sys` prototype, and then write a custom wrapper in
+`syscall_${GOOS}.go`.
+
+### types files
+
+For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
+`types_${GOOS}.go` on the old system). This file includes standard C headers and
+creates Go type aliases to the corresponding C types. The file is then fed
+through godef to get the Go compatible definitions. Finally, the generated code
+is fed though mkpost.go to format the code correctly and remove any hidden or
+private identifiers. This cleaned-up code is written to
+`ztypes_${GOOS}_${GOARCH}.go`.
+
+The hardest part about preparing this file is figuring out which headers to
+include and which symbols need to be `#define`d to get the actual data
+structures that pass through to the kernel system calls. Some C libraries
+preset alternate versions for binary compatibility and translate them on the
+way in and out of system calls, but there is almost always a `#define` that can
+get the real ones.
+See `types_darwin.go` and `linux/types.go` for examples.
+
+To add a new type, add in the necessary include statement at the top of the
+file (if it is not already there) and add in a type alias line. Note that if
+your type is significantly different on different architectures, you may need
+some `#if/#elif` macros in your include statements.
+
+### mkerrors.sh
+
+This script is used to generate the system's various constants. This doesn't
+just include the error numbers and error strings, but also the signal numbers
+and a wide variety of miscellaneous constants. The constants come from the list
+of include files in the `includes_${uname}` variable. A regex then picks out
+the desired `#define` statements, and generates the corresponding Go constants.
+The error numbers and strings are generated from `#include `, and the
+signal numbers and strings are generated from `#include `. All of
+these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
+`_errors.c`, which prints out all the constants.
+
+To add a constant, add the header that includes it to the appropriate variable.
+Then, edit the regex (if necessary) to match the desired constant. Avoid making
+the regex too broad to avoid matching unintended constants.
+
+### internal/mkmerge
+
+This program is used to extract duplicate const, func, and type declarations
+from the generated architecture-specific files listed below, and merge these
+into a common file for each OS.
+
+The merge is performed in the following steps:
+1. Construct the set of common code that is idential in all architecture-specific files.
+2. Write this common code to the merged file.
+3. Remove the common code from all architecture-specific files.
+
+
+## Generated files
+
+### `zerrors_${GOOS}_${GOARCH}.go`
+
+A file containing all of the system's generated error numbers, error strings,
+signal numbers, and constants. Generated by `mkerrors.sh` (see above).
+
+### `zsyscall_${GOOS}_${GOARCH}.go`
+
+A file containing all the generated syscalls for a specific GOOS and GOARCH.
+Generated by `mksyscall.go` (see above).
+
+### `zsysnum_${GOOS}_${GOARCH}.go`
+
+A list of numeric constants for all the syscall number of the specific GOOS
+and GOARCH. Generated by mksysnum (see above).
+
+### `ztypes_${GOOS}_${GOARCH}.go`
+
+A file containing Go types for passing into (or returning from) syscalls.
+Generated by godefs and the types file (see above).
diff --git a/vendor/golang.org/x/sys/unix/affinity_linux.go b/vendor/golang.org/x/sys/unix/affinity_linux.go
new file mode 100644
index 0000000..6e5c81a
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/affinity_linux.go
@@ -0,0 +1,86 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// CPU affinity functions
+
+package unix
+
+import (
+ "math/bits"
+ "unsafe"
+)
+
+const cpuSetSize = _CPU_SETSIZE / _NCPUBITS
+
+// CPUSet represents a CPU affinity mask.
+type CPUSet [cpuSetSize]cpuMask
+
+func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
+ _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set)))
+ if e != 0 {
+ return errnoErr(e)
+ }
+ return nil
+}
+
+// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
+// If pid is 0 the calling thread is used.
+func SchedGetaffinity(pid int, set *CPUSet) error {
+ return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set)
+}
+
+// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
+// If pid is 0 the calling thread is used.
+func SchedSetaffinity(pid int, set *CPUSet) error {
+ return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set)
+}
+
+// Zero clears the set s, so that it contains no CPUs.
+func (s *CPUSet) Zero() {
+ for i := range s {
+ s[i] = 0
+ }
+}
+
+func cpuBitsIndex(cpu int) int {
+ return cpu / _NCPUBITS
+}
+
+func cpuBitsMask(cpu int) cpuMask {
+ return cpuMask(1 << (uint(cpu) % _NCPUBITS))
+}
+
+// Set adds cpu to the set s.
+func (s *CPUSet) Set(cpu int) {
+ i := cpuBitsIndex(cpu)
+ if i < len(s) {
+ s[i] |= cpuBitsMask(cpu)
+ }
+}
+
+// Clear removes cpu from the set s.
+func (s *CPUSet) Clear(cpu int) {
+ i := cpuBitsIndex(cpu)
+ if i < len(s) {
+ s[i] &^= cpuBitsMask(cpu)
+ }
+}
+
+// IsSet reports whether cpu is in the set s.
+func (s *CPUSet) IsSet(cpu int) bool {
+ i := cpuBitsIndex(cpu)
+ if i < len(s) {
+ return s[i]&cpuBitsMask(cpu) != 0
+ }
+ return false
+}
+
+// Count returns the number of CPUs in the set s.
+func (s *CPUSet) Count() int {
+ c := 0
+ for _, b := range s {
+ c += bits.OnesCount64(uint64(b))
+ }
+ return c
+}
diff --git a/vendor/golang.org/x/sys/unix/aliases.go b/vendor/golang.org/x/sys/unix/aliases.go
new file mode 100644
index 0000000..abc89c1
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/aliases.go
@@ -0,0 +1,15 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
+// +build go1.9
+
+package unix
+
+import "syscall"
+
+type Signal = syscall.Signal
+type Errno = syscall.Errno
+type SysProcAttr = syscall.SysProcAttr
diff --git a/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s b/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
new file mode 100644
index 0000000..db9171c
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
@@ -0,0 +1,18 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gc
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go
+//
+
+TEXT ·syscall6(SB),NOSPLIT,$0-88
+ JMP syscall·syscall6(SB)
+
+TEXT ·rawSyscall6(SB),NOSPLIT,$0-88
+ JMP syscall·rawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_386.s b/vendor/golang.org/x/sys/unix/asm_bsd_386.s
new file mode 100644
index 0000000..e0fcd9b
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_bsd_386.s
@@ -0,0 +1,29 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build (freebsd || netbsd || openbsd) && gc
+// +build freebsd netbsd openbsd
+// +build gc
+
+#include "textflag.h"
+
+// System call support for 386 BSD
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s
new file mode 100644
index 0000000..2b99c34
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s
@@ -0,0 +1,29 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc
+// +build darwin dragonfly freebsd netbsd openbsd
+// +build gc
+
+#include "textflag.h"
+
+// System call support for AMD64 BSD
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s
new file mode 100644
index 0000000..d702d4a
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s
@@ -0,0 +1,29 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build (freebsd || netbsd || openbsd) && gc
+// +build freebsd netbsd openbsd
+// +build gc
+
+#include "textflag.h"
+
+// System call support for ARM BSD
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ B syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ B syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ B syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s
new file mode 100644
index 0000000..fe36a73
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s
@@ -0,0 +1,29 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build (darwin || freebsd || netbsd || openbsd) && gc
+// +build darwin freebsd netbsd openbsd
+// +build gc
+
+#include "textflag.h"
+
+// System call support for ARM64 BSD
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_386.s b/vendor/golang.org/x/sys/unix/asm_linux_386.s
new file mode 100644
index 0000000..8fd101d
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_386.s
@@ -0,0 +1,66 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gc
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for 386, Linux
+//
+
+// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
+// instead of the glibc-specific "CALL 0x10(GS)".
+#define INVOKE_SYSCALL INT $0x80
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
+ CALL runtime·entersyscall(SB)
+ MOVL trap+0(FP), AX // syscall entry
+ MOVL a1+4(FP), BX
+ MOVL a2+8(FP), CX
+ MOVL a3+12(FP), DX
+ MOVL $0, SI
+ MOVL $0, DI
+ INVOKE_SYSCALL
+ MOVL AX, r1+16(FP)
+ MOVL DX, r2+20(FP)
+ CALL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
+ MOVL trap+0(FP), AX // syscall entry
+ MOVL a1+4(FP), BX
+ MOVL a2+8(FP), CX
+ MOVL a3+12(FP), DX
+ MOVL $0, SI
+ MOVL $0, DI
+ INVOKE_SYSCALL
+ MOVL AX, r1+16(FP)
+ MOVL DX, r2+20(FP)
+ RET
+
+TEXT ·socketcall(SB),NOSPLIT,$0-36
+ JMP syscall·socketcall(SB)
+
+TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
+ JMP syscall·rawsocketcall(SB)
+
+TEXT ·seek(SB),NOSPLIT,$0-28
+ JMP syscall·seek(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s
new file mode 100644
index 0000000..7ed38e4
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s
@@ -0,0 +1,58 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gc
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for AMD64, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
+ CALL runtime·entersyscall(SB)
+ MOVQ a1+8(FP), DI
+ MOVQ a2+16(FP), SI
+ MOVQ a3+24(FP), DX
+ MOVQ $0, R10
+ MOVQ $0, R8
+ MOVQ $0, R9
+ MOVQ trap+0(FP), AX // syscall entry
+ SYSCALL
+ MOVQ AX, r1+32(FP)
+ MOVQ DX, r2+40(FP)
+ CALL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
+ MOVQ a1+8(FP), DI
+ MOVQ a2+16(FP), SI
+ MOVQ a3+24(FP), DX
+ MOVQ $0, R10
+ MOVQ $0, R8
+ MOVQ $0, R9
+ MOVQ trap+0(FP), AX // syscall entry
+ SYSCALL
+ MOVQ AX, r1+32(FP)
+ MOVQ DX, r2+40(FP)
+ RET
+
+TEXT ·gettimeofday(SB),NOSPLIT,$0-16
+ JMP syscall·gettimeofday(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm.s b/vendor/golang.org/x/sys/unix/asm_linux_arm.s
new file mode 100644
index 0000000..8ef1d51
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_arm.s
@@ -0,0 +1,57 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gc
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for arm, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ B syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
+ BL runtime·entersyscall(SB)
+ MOVW trap+0(FP), R7
+ MOVW a1+4(FP), R0
+ MOVW a2+8(FP), R1
+ MOVW a3+12(FP), R2
+ MOVW $0, R3
+ MOVW $0, R4
+ MOVW $0, R5
+ SWI $0
+ MOVW R0, r1+16(FP)
+ MOVW $0, R0
+ MOVW R0, r2+20(FP)
+ BL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ B syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
+ MOVW trap+0(FP), R7 // syscall entry
+ MOVW a1+4(FP), R0
+ MOVW a2+8(FP), R1
+ MOVW a3+12(FP), R2
+ SWI $0
+ MOVW R0, r1+16(FP)
+ MOVW $0, R0
+ MOVW R0, r2+20(FP)
+ RET
+
+TEXT ·seek(SB),NOSPLIT,$0-28
+ B syscall·seek(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s
new file mode 100644
index 0000000..98ae027
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s
@@ -0,0 +1,53 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux && arm64 && gc
+// +build linux
+// +build arm64
+// +build gc
+
+#include "textflag.h"
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ B syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ B syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
+ BL runtime·entersyscall(SB)
+ MOVD a1+8(FP), R0
+ MOVD a2+16(FP), R1
+ MOVD a3+24(FP), R2
+ MOVD $0, R3
+ MOVD $0, R4
+ MOVD $0, R5
+ MOVD trap+0(FP), R8 // syscall entry
+ SVC
+ MOVD R0, r1+32(FP) // r1
+ MOVD R1, r2+40(FP) // r2
+ BL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ B syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ B syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
+ MOVD a1+8(FP), R0
+ MOVD a2+16(FP), R1
+ MOVD a3+24(FP), R2
+ MOVD $0, R3
+ MOVD $0, R4
+ MOVD $0, R5
+ MOVD trap+0(FP), R8 // syscall entry
+ SVC
+ MOVD R0, r1+32(FP)
+ MOVD R1, r2+40(FP)
+ RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s
new file mode 100644
index 0000000..6abd48e
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s
@@ -0,0 +1,54 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux && loong64 && gc
+// +build linux
+// +build loong64
+// +build gc
+
+#include "textflag.h"
+
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
+ JAL runtime·entersyscall(SB)
+ MOVV a1+8(FP), R4
+ MOVV a2+16(FP), R5
+ MOVV a3+24(FP), R6
+ MOVV R0, R7
+ MOVV R0, R8
+ MOVV R0, R9
+ MOVV trap+0(FP), R11 // syscall entry
+ SYSCALL
+ MOVV R4, r1+32(FP)
+ MOVV R5, r2+40(FP)
+ JAL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
+ MOVV a1+8(FP), R4
+ MOVV a2+16(FP), R5
+ MOVV a3+24(FP), R6
+ MOVV R0, R7
+ MOVV R0, R8
+ MOVV R0, R9
+ MOVV trap+0(FP), R11 // syscall entry
+ SYSCALL
+ MOVV R4, r1+32(FP)
+ MOVV R5, r2+40(FP)
+ RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
new file mode 100644
index 0000000..21231d2
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
@@ -0,0 +1,57 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux && (mips64 || mips64le) && gc
+// +build linux
+// +build mips64 mips64le
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for mips64, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
+ JAL runtime·entersyscall(SB)
+ MOVV a1+8(FP), R4
+ MOVV a2+16(FP), R5
+ MOVV a3+24(FP), R6
+ MOVV R0, R7
+ MOVV R0, R8
+ MOVV R0, R9
+ MOVV trap+0(FP), R2 // syscall entry
+ SYSCALL
+ MOVV R2, r1+32(FP)
+ MOVV R3, r2+40(FP)
+ JAL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
+ MOVV a1+8(FP), R4
+ MOVV a2+16(FP), R5
+ MOVV a3+24(FP), R6
+ MOVV R0, R7
+ MOVV R0, R8
+ MOVV R0, R9
+ MOVV trap+0(FP), R2 // syscall entry
+ SYSCALL
+ MOVV R2, r1+32(FP)
+ MOVV R3, r2+40(FP)
+ RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s b/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
new file mode 100644
index 0000000..6783b26
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
@@ -0,0 +1,55 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux && (mips || mipsle) && gc
+// +build linux
+// +build mips mipsle
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for mips, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-28
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
+ JMP syscall·Syscall9(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
+ JAL runtime·entersyscall(SB)
+ MOVW a1+4(FP), R4
+ MOVW a2+8(FP), R5
+ MOVW a3+12(FP), R6
+ MOVW R0, R7
+ MOVW trap+0(FP), R2 // syscall entry
+ SYSCALL
+ MOVW R2, r1+16(FP) // r1
+ MOVW R3, r2+20(FP) // r2
+ JAL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
+ MOVW a1+4(FP), R4
+ MOVW a2+8(FP), R5
+ MOVW a3+12(FP), R6
+ MOVW trap+0(FP), R2 // syscall entry
+ SYSCALL
+ MOVW R2, r1+16(FP)
+ MOVW R3, r2+20(FP)
+ RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
new file mode 100644
index 0000000..19d4989
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
@@ -0,0 +1,45 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux && (ppc64 || ppc64le) && gc
+// +build linux
+// +build ppc64 ppc64le
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for ppc64, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
+ BL runtime·entersyscall(SB)
+ MOVD a1+8(FP), R3
+ MOVD a2+16(FP), R4
+ MOVD a3+24(FP), R5
+ MOVD R0, R6
+ MOVD R0, R7
+ MOVD R0, R8
+ MOVD trap+0(FP), R9 // syscall entry
+ SYSCALL R9
+ MOVD R3, r1+32(FP)
+ MOVD R4, r2+40(FP)
+ BL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
+ MOVD a1+8(FP), R3
+ MOVD a2+16(FP), R4
+ MOVD a3+24(FP), R5
+ MOVD R0, R6
+ MOVD R0, R7
+ MOVD R0, R8
+ MOVD trap+0(FP), R9 // syscall entry
+ SYSCALL R9
+ MOVD R3, r1+32(FP)
+ MOVD R4, r2+40(FP)
+ RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s b/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
new file mode 100644
index 0000000..e42eb81
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
@@ -0,0 +1,49 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build riscv64 && gc
+// +build riscv64
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for linux/riscv64.
+//
+// Where available, just jump to package syscall's implementation of
+// these functions.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
+ CALL runtime·entersyscall(SB)
+ MOV a1+8(FP), A0
+ MOV a2+16(FP), A1
+ MOV a3+24(FP), A2
+ MOV trap+0(FP), A7 // syscall entry
+ ECALL
+ MOV A0, r1+32(FP) // r1
+ MOV A1, r2+40(FP) // r2
+ CALL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
+ MOV a1+8(FP), A0
+ MOV a2+16(FP), A1
+ MOV a3+24(FP), A2
+ MOV trap+0(FP), A7 // syscall entry
+ ECALL
+ MOV A0, r1+32(FP)
+ MOV A1, r2+40(FP)
+ RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s
new file mode 100644
index 0000000..c46aab3
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s
@@ -0,0 +1,57 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux && s390x && gc
+// +build linux
+// +build s390x
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for s390x, Linux
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ BR syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ BR syscall·Syscall6(SB)
+
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
+ BL runtime·entersyscall(SB)
+ MOVD a1+8(FP), R2
+ MOVD a2+16(FP), R3
+ MOVD a3+24(FP), R4
+ MOVD $0, R5
+ MOVD $0, R6
+ MOVD $0, R7
+ MOVD trap+0(FP), R1 // syscall entry
+ SYSCALL
+ MOVD R2, r1+32(FP)
+ MOVD R3, r2+40(FP)
+ BL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ BR syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ BR syscall·RawSyscall6(SB)
+
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
+ MOVD a1+8(FP), R2
+ MOVD a2+16(FP), R3
+ MOVD a3+24(FP), R4
+ MOVD $0, R5
+ MOVD $0, R6
+ MOVD $0, R7
+ MOVD trap+0(FP), R1 // syscall entry
+ SYSCALL
+ MOVD R2, r1+32(FP)
+ MOVD R3, r2+40(FP)
+ RET
diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
new file mode 100644
index 0000000..5e7a116
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
@@ -0,0 +1,30 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gc
+// +build gc
+
+#include "textflag.h"
+
+//
+// System call support for mips64, OpenBSD
+//
+
+// Just jump to package syscall's implementation for all these functions.
+// The runtime may know about them.
+
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+ JMP syscall·Syscall(SB)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+ JMP syscall·Syscall6(SB)
+
+TEXT ·Syscall9(SB),NOSPLIT,$0-104
+ JMP syscall·Syscall9(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+ JMP syscall·RawSyscall(SB)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+ JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
new file mode 100644
index 0000000..f8c5394
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
@@ -0,0 +1,18 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gc
+// +build gc
+
+#include "textflag.h"
+
+//
+// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
+//
+
+TEXT ·sysvicall6(SB),NOSPLIT,$0-88
+ JMP syscall·sysvicall6(SB)
+
+TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
+ JMP syscall·rawSysvicall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s
new file mode 100644
index 0000000..3b54e18
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s
@@ -0,0 +1,426 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build zos && s390x && gc
+// +build zos
+// +build s390x
+// +build gc
+
+#include "textflag.h"
+
+#define PSALAA 1208(R0)
+#define GTAB64(x) 80(x)
+#define LCA64(x) 88(x)
+#define CAA(x) 8(x)
+#define EDCHPXV(x) 1016(x) // in the CAA
+#define SAVSTACK_ASYNC(x) 336(x) // in the LCA
+
+// SS_*, where x=SAVSTACK_ASYNC
+#define SS_LE(x) 0(x)
+#define SS_GO(x) 8(x)
+#define SS_ERRNO(x) 16(x)
+#define SS_ERRNOJR(x) 20(x)
+
+#define LE_CALL BYTE $0x0D; BYTE $0x76; // BL R7, R6
+
+TEXT ·clearErrno(SB),NOSPLIT,$0-0
+ BL addrerrno<>(SB)
+ MOVD $0, 0(R3)
+ RET
+
+// Returns the address of errno in R3.
+TEXT addrerrno<>(SB),NOSPLIT|NOFRAME,$0-0
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get __errno FuncDesc.
+ MOVD CAA(R8), R9
+ MOVD EDCHPXV(R9), R9
+ ADD $(0x156*16), R9
+ LMG 0(R9), R5, R6
+
+ // Switch to saved LE stack.
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R4
+ MOVD $0, 0(R9)
+
+ // Call __errno function.
+ LE_CALL
+ NOPH
+
+ // Switch back to Go stack.
+ XOR R0, R0 // Restore R0 to $0.
+ MOVD R4, 0(R9) // Save stack pointer.
+ RET
+
+TEXT ·syscall_syscall(SB),NOSPLIT,$0-56
+ BL runtime·entersyscall(SB)
+ MOVD a1+8(FP), R1
+ MOVD a2+16(FP), R2
+ MOVD a3+24(FP), R3
+
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get function.
+ MOVD CAA(R8), R9
+ MOVD EDCHPXV(R9), R9
+ MOVD trap+0(FP), R5
+ SLD $4, R5
+ ADD R5, R9
+ LMG 0(R9), R5, R6
+
+ // Restore LE stack.
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R4
+ MOVD $0, 0(R9)
+
+ // Call function.
+ LE_CALL
+ NOPH
+ XOR R0, R0 // Restore R0 to $0.
+ MOVD R4, 0(R9) // Save stack pointer.
+
+ MOVD R3, r1+32(FP)
+ MOVD R0, r2+40(FP)
+ MOVD R0, err+48(FP)
+ MOVW R3, R4
+ CMP R4, $-1
+ BNE done
+ BL addrerrno<>(SB)
+ MOVWZ 0(R3), R3
+ MOVD R3, err+48(FP)
+done:
+ BL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·syscall_rawsyscall(SB),NOSPLIT,$0-56
+ MOVD a1+8(FP), R1
+ MOVD a2+16(FP), R2
+ MOVD a3+24(FP), R3
+
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get function.
+ MOVD CAA(R8), R9
+ MOVD EDCHPXV(R9), R9
+ MOVD trap+0(FP), R5
+ SLD $4, R5
+ ADD R5, R9
+ LMG 0(R9), R5, R6
+
+ // Restore LE stack.
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R4
+ MOVD $0, 0(R9)
+
+ // Call function.
+ LE_CALL
+ NOPH
+ XOR R0, R0 // Restore R0 to $0.
+ MOVD R4, 0(R9) // Save stack pointer.
+
+ MOVD R3, r1+32(FP)
+ MOVD R0, r2+40(FP)
+ MOVD R0, err+48(FP)
+ MOVW R3, R4
+ CMP R4, $-1
+ BNE done
+ BL addrerrno<>(SB)
+ MOVWZ 0(R3), R3
+ MOVD R3, err+48(FP)
+done:
+ RET
+
+TEXT ·syscall_syscall6(SB),NOSPLIT,$0-80
+ BL runtime·entersyscall(SB)
+ MOVD a1+8(FP), R1
+ MOVD a2+16(FP), R2
+ MOVD a3+24(FP), R3
+
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get function.
+ MOVD CAA(R8), R9
+ MOVD EDCHPXV(R9), R9
+ MOVD trap+0(FP), R5
+ SLD $4, R5
+ ADD R5, R9
+ LMG 0(R9), R5, R6
+
+ // Restore LE stack.
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R4
+ MOVD $0, 0(R9)
+
+ // Fill in parameter list.
+ MOVD a4+32(FP), R12
+ MOVD R12, (2176+24)(R4)
+ MOVD a5+40(FP), R12
+ MOVD R12, (2176+32)(R4)
+ MOVD a6+48(FP), R12
+ MOVD R12, (2176+40)(R4)
+
+ // Call function.
+ LE_CALL
+ NOPH
+ XOR R0, R0 // Restore R0 to $0.
+ MOVD R4, 0(R9) // Save stack pointer.
+
+ MOVD R3, r1+56(FP)
+ MOVD R0, r2+64(FP)
+ MOVD R0, err+72(FP)
+ MOVW R3, R4
+ CMP R4, $-1
+ BNE done
+ BL addrerrno<>(SB)
+ MOVWZ 0(R3), R3
+ MOVD R3, err+72(FP)
+done:
+ BL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·syscall_rawsyscall6(SB),NOSPLIT,$0-80
+ MOVD a1+8(FP), R1
+ MOVD a2+16(FP), R2
+ MOVD a3+24(FP), R3
+
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get function.
+ MOVD CAA(R8), R9
+ MOVD EDCHPXV(R9), R9
+ MOVD trap+0(FP), R5
+ SLD $4, R5
+ ADD R5, R9
+ LMG 0(R9), R5, R6
+
+ // Restore LE stack.
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R4
+ MOVD $0, 0(R9)
+
+ // Fill in parameter list.
+ MOVD a4+32(FP), R12
+ MOVD R12, (2176+24)(R4)
+ MOVD a5+40(FP), R12
+ MOVD R12, (2176+32)(R4)
+ MOVD a6+48(FP), R12
+ MOVD R12, (2176+40)(R4)
+
+ // Call function.
+ LE_CALL
+ NOPH
+ XOR R0, R0 // Restore R0 to $0.
+ MOVD R4, 0(R9) // Save stack pointer.
+
+ MOVD R3, r1+56(FP)
+ MOVD R0, r2+64(FP)
+ MOVD R0, err+72(FP)
+ MOVW R3, R4
+ CMP R4, $-1
+ BNE done
+ BL ·rrno<>(SB)
+ MOVWZ 0(R3), R3
+ MOVD R3, err+72(FP)
+done:
+ RET
+
+TEXT ·syscall_syscall9(SB),NOSPLIT,$0
+ BL runtime·entersyscall(SB)
+ MOVD a1+8(FP), R1
+ MOVD a2+16(FP), R2
+ MOVD a3+24(FP), R3
+
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get function.
+ MOVD CAA(R8), R9
+ MOVD EDCHPXV(R9), R9
+ MOVD trap+0(FP), R5
+ SLD $4, R5
+ ADD R5, R9
+ LMG 0(R9), R5, R6
+
+ // Restore LE stack.
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R4
+ MOVD $0, 0(R9)
+
+ // Fill in parameter list.
+ MOVD a4+32(FP), R12
+ MOVD R12, (2176+24)(R4)
+ MOVD a5+40(FP), R12
+ MOVD R12, (2176+32)(R4)
+ MOVD a6+48(FP), R12
+ MOVD R12, (2176+40)(R4)
+ MOVD a7+56(FP), R12
+ MOVD R12, (2176+48)(R4)
+ MOVD a8+64(FP), R12
+ MOVD R12, (2176+56)(R4)
+ MOVD a9+72(FP), R12
+ MOVD R12, (2176+64)(R4)
+
+ // Call function.
+ LE_CALL
+ NOPH
+ XOR R0, R0 // Restore R0 to $0.
+ MOVD R4, 0(R9) // Save stack pointer.
+
+ MOVD R3, r1+80(FP)
+ MOVD R0, r2+88(FP)
+ MOVD R0, err+96(FP)
+ MOVW R3, R4
+ CMP R4, $-1
+ BNE done
+ BL addrerrno<>(SB)
+ MOVWZ 0(R3), R3
+ MOVD R3, err+96(FP)
+done:
+ BL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·syscall_rawsyscall9(SB),NOSPLIT,$0
+ MOVD a1+8(FP), R1
+ MOVD a2+16(FP), R2
+ MOVD a3+24(FP), R3
+
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get function.
+ MOVD CAA(R8), R9
+ MOVD EDCHPXV(R9), R9
+ MOVD trap+0(FP), R5
+ SLD $4, R5
+ ADD R5, R9
+ LMG 0(R9), R5, R6
+
+ // Restore LE stack.
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R4
+ MOVD $0, 0(R9)
+
+ // Fill in parameter list.
+ MOVD a4+32(FP), R12
+ MOVD R12, (2176+24)(R4)
+ MOVD a5+40(FP), R12
+ MOVD R12, (2176+32)(R4)
+ MOVD a6+48(FP), R12
+ MOVD R12, (2176+40)(R4)
+ MOVD a7+56(FP), R12
+ MOVD R12, (2176+48)(R4)
+ MOVD a8+64(FP), R12
+ MOVD R12, (2176+56)(R4)
+ MOVD a9+72(FP), R12
+ MOVD R12, (2176+64)(R4)
+
+ // Call function.
+ LE_CALL
+ NOPH
+ XOR R0, R0 // Restore R0 to $0.
+ MOVD R4, 0(R9) // Save stack pointer.
+
+ MOVD R3, r1+80(FP)
+ MOVD R0, r2+88(FP)
+ MOVD R0, err+96(FP)
+ MOVW R3, R4
+ CMP R4, $-1
+ BNE done
+ BL addrerrno<>(SB)
+ MOVWZ 0(R3), R3
+ MOVD R3, err+96(FP)
+done:
+ RET
+
+// func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64)
+TEXT ·svcCall(SB),NOSPLIT,$0
+ BL runtime·save_g(SB) // Save g and stack pointer
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD R15, 0(R9)
+
+ MOVD argv+8(FP), R1 // Move function arguments into registers
+ MOVD dsa+16(FP), g
+ MOVD fnptr+0(FP), R15
+
+ BYTE $0x0D // Branch to function
+ BYTE $0xEF
+
+ BL runtime·load_g(SB) // Restore g and stack pointer
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+ MOVD SAVSTACK_ASYNC(R8), R9
+ MOVD 0(R9), R15
+
+ RET
+
+// func svcLoad(name *byte) unsafe.Pointer
+TEXT ·svcLoad(SB),NOSPLIT,$0
+ MOVD R15, R2 // Save go stack pointer
+ MOVD name+0(FP), R0 // Move SVC args into registers
+ MOVD $0x80000000, R1
+ MOVD $0, R15
+ BYTE $0x0A // SVC 08 LOAD
+ BYTE $0x08
+ MOVW R15, R3 // Save return code from SVC
+ MOVD R2, R15 // Restore go stack pointer
+ CMP R3, $0 // Check SVC return code
+ BNE error
+
+ MOVD $-2, R3 // Reset last bit of entry point to zero
+ AND R0, R3
+ MOVD R3, addr+8(FP) // Return entry point returned by SVC
+ CMP R0, R3 // Check if last bit of entry point was set
+ BNE done
+
+ MOVD R15, R2 // Save go stack pointer
+ MOVD $0, R15 // Move SVC args into registers (entry point still in r0 from SVC 08)
+ BYTE $0x0A // SVC 09 DELETE
+ BYTE $0x09
+ MOVD R2, R15 // Restore go stack pointer
+
+error:
+ MOVD $0, addr+8(FP) // Return 0 on failure
+done:
+ XOR R0, R0 // Reset r0 to 0
+ RET
+
+// func svcUnload(name *byte, fnptr unsafe.Pointer) int64
+TEXT ·svcUnload(SB),NOSPLIT,$0
+ MOVD R15, R2 // Save go stack pointer
+ MOVD name+0(FP), R0 // Move SVC args into registers
+ MOVD addr+8(FP), R15
+ BYTE $0x0A // SVC 09
+ BYTE $0x09
+ XOR R0, R0 // Reset r0 to 0
+ MOVD R15, R1 // Save SVC return code
+ MOVD R2, R15 // Restore go stack pointer
+ MOVD R1, rc+0(FP) // Return SVC return code
+ RET
+
+// func gettid() uint64
+TEXT ·gettid(SB), NOSPLIT, $0
+ // Get library control area (LCA).
+ MOVW PSALAA, R8
+ MOVD LCA64(R8), R8
+
+ // Get CEECAATHDID
+ MOVD CAA(R8), R9
+ MOVD 0x3D0(R9), R9
+ MOVD R9, ret+0(FP)
+
+ RET
diff --git a/vendor/golang.org/x/sys/unix/bluetooth_linux.go b/vendor/golang.org/x/sys/unix/bluetooth_linux.go
new file mode 100644
index 0000000..a178a61
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/bluetooth_linux.go
@@ -0,0 +1,36 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Bluetooth sockets and messages
+
+package unix
+
+// Bluetooth Protocols
+const (
+ BTPROTO_L2CAP = 0
+ BTPROTO_HCI = 1
+ BTPROTO_SCO = 2
+ BTPROTO_RFCOMM = 3
+ BTPROTO_BNEP = 4
+ BTPROTO_CMTP = 5
+ BTPROTO_HIDP = 6
+ BTPROTO_AVDTP = 7
+)
+
+const (
+ HCI_CHANNEL_RAW = 0
+ HCI_CHANNEL_USER = 1
+ HCI_CHANNEL_MONITOR = 2
+ HCI_CHANNEL_CONTROL = 3
+ HCI_CHANNEL_LOGGING = 4
+)
+
+// Socketoption Level
+const (
+ SOL_BLUETOOTH = 0x112
+ SOL_HCI = 0x0
+ SOL_L2CAP = 0x6
+ SOL_RFCOMM = 0x12
+ SOL_SCO = 0x11
+)
diff --git a/vendor/golang.org/x/sys/unix/cap_freebsd.go b/vendor/golang.org/x/sys/unix/cap_freebsd.go
new file mode 100644
index 0000000..0b7c6ad
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/cap_freebsd.go
@@ -0,0 +1,196 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build freebsd
+// +build freebsd
+
+package unix
+
+import (
+ "errors"
+ "fmt"
+)
+
+// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
+
+const (
+ // This is the version of CapRights this package understands. See C implementation for parallels.
+ capRightsGoVersion = CAP_RIGHTS_VERSION_00
+ capArSizeMin = CAP_RIGHTS_VERSION_00 + 2
+ capArSizeMax = capRightsGoVersion + 2
+)
+
+var (
+ bit2idx = []int{
+ -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
+ 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ }
+)
+
+func capidxbit(right uint64) int {
+ return int((right >> 57) & 0x1f)
+}
+
+func rightToIndex(right uint64) (int, error) {
+ idx := capidxbit(right)
+ if idx < 0 || idx >= len(bit2idx) {
+ return -2, fmt.Errorf("index for right 0x%x out of range", right)
+ }
+ return bit2idx[idx], nil
+}
+
+func caprver(right uint64) int {
+ return int(right >> 62)
+}
+
+func capver(rights *CapRights) int {
+ return caprver(rights.Rights[0])
+}
+
+func caparsize(rights *CapRights) int {
+ return capver(rights) + 2
+}
+
+// CapRightsSet sets the permissions in setrights in rights.
+func CapRightsSet(rights *CapRights, setrights []uint64) error {
+ // This is essentially a copy of cap_rights_vset()
+ if capver(rights) != CAP_RIGHTS_VERSION_00 {
+ return fmt.Errorf("bad rights version %d", capver(rights))
+ }
+
+ n := caparsize(rights)
+ if n < capArSizeMin || n > capArSizeMax {
+ return errors.New("bad rights size")
+ }
+
+ for _, right := range setrights {
+ if caprver(right) != CAP_RIGHTS_VERSION_00 {
+ return errors.New("bad right version")
+ }
+ i, err := rightToIndex(right)
+ if err != nil {
+ return err
+ }
+ if i >= n {
+ return errors.New("index overflow")
+ }
+ if capidxbit(rights.Rights[i]) != capidxbit(right) {
+ return errors.New("index mismatch")
+ }
+ rights.Rights[i] |= right
+ if capidxbit(rights.Rights[i]) != capidxbit(right) {
+ return errors.New("index mismatch (after assign)")
+ }
+ }
+
+ return nil
+}
+
+// CapRightsClear clears the permissions in clearrights from rights.
+func CapRightsClear(rights *CapRights, clearrights []uint64) error {
+ // This is essentially a copy of cap_rights_vclear()
+ if capver(rights) != CAP_RIGHTS_VERSION_00 {
+ return fmt.Errorf("bad rights version %d", capver(rights))
+ }
+
+ n := caparsize(rights)
+ if n < capArSizeMin || n > capArSizeMax {
+ return errors.New("bad rights size")
+ }
+
+ for _, right := range clearrights {
+ if caprver(right) != CAP_RIGHTS_VERSION_00 {
+ return errors.New("bad right version")
+ }
+ i, err := rightToIndex(right)
+ if err != nil {
+ return err
+ }
+ if i >= n {
+ return errors.New("index overflow")
+ }
+ if capidxbit(rights.Rights[i]) != capidxbit(right) {
+ return errors.New("index mismatch")
+ }
+ rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
+ if capidxbit(rights.Rights[i]) != capidxbit(right) {
+ return errors.New("index mismatch (after assign)")
+ }
+ }
+
+ return nil
+}
+
+// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
+func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
+ // This is essentially a copy of cap_rights_is_vset()
+ if capver(rights) != CAP_RIGHTS_VERSION_00 {
+ return false, fmt.Errorf("bad rights version %d", capver(rights))
+ }
+
+ n := caparsize(rights)
+ if n < capArSizeMin || n > capArSizeMax {
+ return false, errors.New("bad rights size")
+ }
+
+ for _, right := range setrights {
+ if caprver(right) != CAP_RIGHTS_VERSION_00 {
+ return false, errors.New("bad right version")
+ }
+ i, err := rightToIndex(right)
+ if err != nil {
+ return false, err
+ }
+ if i >= n {
+ return false, errors.New("index overflow")
+ }
+ if capidxbit(rights.Rights[i]) != capidxbit(right) {
+ return false, errors.New("index mismatch")
+ }
+ if (rights.Rights[i] & right) != right {
+ return false, nil
+ }
+ }
+
+ return true, nil
+}
+
+func capright(idx uint64, bit uint64) uint64 {
+ return ((1 << (57 + idx)) | bit)
+}
+
+// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
+// See man cap_rights_init(3) and rights(4).
+func CapRightsInit(rights []uint64) (*CapRights, error) {
+ var r CapRights
+ r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
+ r.Rights[1] = capright(1, 0)
+
+ err := CapRightsSet(&r, rights)
+ if err != nil {
+ return nil, err
+ }
+ return &r, nil
+}
+
+// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
+// The capability rights on fd can never be increased by CapRightsLimit.
+// See man cap_rights_limit(2) and rights(4).
+func CapRightsLimit(fd uintptr, rights *CapRights) error {
+ return capRightsLimit(int(fd), rights)
+}
+
+// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
+// See man cap_rights_get(3) and rights(4).
+func CapRightsGet(fd uintptr) (*CapRights, error) {
+ r, err := CapRightsInit(nil)
+ if err != nil {
+ return nil, err
+ }
+ err = capRightsGet(capRightsGoVersion, int(fd), r)
+ if err != nil {
+ return nil, err
+ }
+ return r, nil
+}
diff --git a/vendor/golang.org/x/sys/unix/constants.go b/vendor/golang.org/x/sys/unix/constants.go
new file mode 100644
index 0000000..394a396
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/constants.go
@@ -0,0 +1,14 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
+
+package unix
+
+const (
+ R_OK = 0x4
+ W_OK = 0x2
+ X_OK = 0x1
+)
diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
new file mode 100644
index 0000000..65a9985
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
@@ -0,0 +1,27 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build aix && ppc
+// +build aix,ppc
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used by AIX.
+
+package unix
+
+// Major returns the major component of a Linux device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev >> 16) & 0xffff)
+}
+
+// Minor returns the minor component of a Linux device number.
+func Minor(dev uint64) uint32 {
+ return uint32(dev & 0xffff)
+}
+
+// Mkdev returns a Linux device number generated from the given major and minor
+// components.
+func Mkdev(major, minor uint32) uint64 {
+ return uint64(((major) << 16) | (minor))
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
new file mode 100644
index 0000000..8fc08ad
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
@@ -0,0 +1,29 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build aix && ppc64
+// +build aix,ppc64
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used AIX.
+
+package unix
+
+// Major returns the major component of a Linux device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev & 0x3fffffff00000000) >> 32)
+}
+
+// Minor returns the minor component of a Linux device number.
+func Minor(dev uint64) uint32 {
+ return uint32((dev & 0x00000000ffffffff) >> 0)
+}
+
+// Mkdev returns a Linux device number generated from the given major and minor
+// components.
+func Mkdev(major, minor uint32) uint64 {
+ var DEVNO64 uint64
+ DEVNO64 = 0x8000000000000000
+ return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64)
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_darwin.go b/vendor/golang.org/x/sys/unix/dev_darwin.go
new file mode 100644
index 0000000..8d1dc0f
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_darwin.go
@@ -0,0 +1,24 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used in Darwin's sys/types.h header.
+
+package unix
+
+// Major returns the major component of a Darwin device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev >> 24) & 0xff)
+}
+
+// Minor returns the minor component of a Darwin device number.
+func Minor(dev uint64) uint32 {
+ return uint32(dev & 0xffffff)
+}
+
+// Mkdev returns a Darwin device number generated from the given major and minor
+// components.
+func Mkdev(major, minor uint32) uint64 {
+ return (uint64(major) << 24) | uint64(minor)
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_dragonfly.go b/vendor/golang.org/x/sys/unix/dev_dragonfly.go
new file mode 100644
index 0000000..8502f20
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_dragonfly.go
@@ -0,0 +1,30 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used in Dragonfly's sys/types.h header.
+//
+// The information below is extracted and adapted from sys/types.h:
+//
+// Minor gives a cookie instead of an index since in order to avoid changing the
+// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
+// devices that don't use them.
+
+package unix
+
+// Major returns the major component of a DragonFlyBSD device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev >> 8) & 0xff)
+}
+
+// Minor returns the minor component of a DragonFlyBSD device number.
+func Minor(dev uint64) uint32 {
+ return uint32(dev & 0xffff00ff)
+}
+
+// Mkdev returns a DragonFlyBSD device number generated from the given major and
+// minor components.
+func Mkdev(major, minor uint32) uint64 {
+ return (uint64(major) << 8) | uint64(minor)
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_freebsd.go b/vendor/golang.org/x/sys/unix/dev_freebsd.go
new file mode 100644
index 0000000..eba3b4b
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_freebsd.go
@@ -0,0 +1,30 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used in FreeBSD's sys/types.h header.
+//
+// The information below is extracted and adapted from sys/types.h:
+//
+// Minor gives a cookie instead of an index since in order to avoid changing the
+// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
+// devices that don't use them.
+
+package unix
+
+// Major returns the major component of a FreeBSD device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev >> 8) & 0xff)
+}
+
+// Minor returns the minor component of a FreeBSD device number.
+func Minor(dev uint64) uint32 {
+ return uint32(dev & 0xffff00ff)
+}
+
+// Mkdev returns a FreeBSD device number generated from the given major and
+// minor components.
+func Mkdev(major, minor uint32) uint64 {
+ return (uint64(major) << 8) | uint64(minor)
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_linux.go b/vendor/golang.org/x/sys/unix/dev_linux.go
new file mode 100644
index 0000000..d165d6f
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_linux.go
@@ -0,0 +1,42 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used by the Linux kernel and glibc.
+//
+// The information below is extracted and adapted from bits/sysmacros.h in the
+// glibc sources:
+//
+// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
+// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
+// number and m is a hex digit of the minor number. This is backward compatible
+// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
+// backward compatible with the Linux kernel, which for some architectures uses
+// 32-bit dev_t, encoded as mmmM MMmm.
+
+package unix
+
+// Major returns the major component of a Linux device number.
+func Major(dev uint64) uint32 {
+ major := uint32((dev & 0x00000000000fff00) >> 8)
+ major |= uint32((dev & 0xfffff00000000000) >> 32)
+ return major
+}
+
+// Minor returns the minor component of a Linux device number.
+func Minor(dev uint64) uint32 {
+ minor := uint32((dev & 0x00000000000000ff) >> 0)
+ minor |= uint32((dev & 0x00000ffffff00000) >> 12)
+ return minor
+}
+
+// Mkdev returns a Linux device number generated from the given major and minor
+// components.
+func Mkdev(major, minor uint32) uint64 {
+ dev := (uint64(major) & 0x00000fff) << 8
+ dev |= (uint64(major) & 0xfffff000) << 32
+ dev |= (uint64(minor) & 0x000000ff) << 0
+ dev |= (uint64(minor) & 0xffffff00) << 12
+ return dev
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_netbsd.go b/vendor/golang.org/x/sys/unix/dev_netbsd.go
new file mode 100644
index 0000000..b4a203d
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_netbsd.go
@@ -0,0 +1,29 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used in NetBSD's sys/types.h header.
+
+package unix
+
+// Major returns the major component of a NetBSD device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev & 0x000fff00) >> 8)
+}
+
+// Minor returns the minor component of a NetBSD device number.
+func Minor(dev uint64) uint32 {
+ minor := uint32((dev & 0x000000ff) >> 0)
+ minor |= uint32((dev & 0xfff00000) >> 12)
+ return minor
+}
+
+// Mkdev returns a NetBSD device number generated from the given major and minor
+// components.
+func Mkdev(major, minor uint32) uint64 {
+ dev := (uint64(major) << 8) & 0x000fff00
+ dev |= (uint64(minor) << 12) & 0xfff00000
+ dev |= (uint64(minor) << 0) & 0x000000ff
+ return dev
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_openbsd.go b/vendor/golang.org/x/sys/unix/dev_openbsd.go
new file mode 100644
index 0000000..f3430c4
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_openbsd.go
@@ -0,0 +1,29 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used in OpenBSD's sys/types.h header.
+
+package unix
+
+// Major returns the major component of an OpenBSD device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev & 0x0000ff00) >> 8)
+}
+
+// Minor returns the minor component of an OpenBSD device number.
+func Minor(dev uint64) uint32 {
+ minor := uint32((dev & 0x000000ff) >> 0)
+ minor |= uint32((dev & 0xffff0000) >> 8)
+ return minor
+}
+
+// Mkdev returns an OpenBSD device number generated from the given major and minor
+// components.
+func Mkdev(major, minor uint32) uint64 {
+ dev := (uint64(major) << 8) & 0x0000ff00
+ dev |= (uint64(minor) << 8) & 0xffff0000
+ dev |= (uint64(minor) << 0) & 0x000000ff
+ return dev
+}
diff --git a/vendor/golang.org/x/sys/unix/dev_zos.go b/vendor/golang.org/x/sys/unix/dev_zos.go
new file mode 100644
index 0000000..a388e59
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dev_zos.go
@@ -0,0 +1,29 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build zos && s390x
+// +build zos,s390x
+
+// Functions to access/create device major and minor numbers matching the
+// encoding used by z/OS.
+//
+// The information below is extracted and adapted from macros.
+
+package unix
+
+// Major returns the major component of a z/OS device number.
+func Major(dev uint64) uint32 {
+ return uint32((dev >> 16) & 0x0000FFFF)
+}
+
+// Minor returns the minor component of a z/OS device number.
+func Minor(dev uint64) uint32 {
+ return uint32(dev & 0x0000FFFF)
+}
+
+// Mkdev returns a z/OS device number generated from the given major and minor
+// components.
+func Mkdev(major, minor uint32) uint64 {
+ return (uint64(major) << 16) | uint64(minor)
+}
diff --git a/vendor/golang.org/x/sys/unix/dirent.go b/vendor/golang.org/x/sys/unix/dirent.go
new file mode 100644
index 0000000..e74e5ea
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/dirent.go
@@ -0,0 +1,103 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package unix
+
+import "unsafe"
+
+// readInt returns the size-bytes unsigned integer in native byte order at offset off.
+func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
+ if len(b) < int(off+size) {
+ return 0, false
+ }
+ if isBigEndian {
+ return readIntBE(b[off:], size), true
+ }
+ return readIntLE(b[off:], size), true
+}
+
+func readIntBE(b []byte, size uintptr) uint64 {
+ switch size {
+ case 1:
+ return uint64(b[0])
+ case 2:
+ _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
+ return uint64(b[1]) | uint64(b[0])<<8
+ case 4:
+ _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
+ return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
+ case 8:
+ _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
+ return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
+ uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
+ default:
+ panic("syscall: readInt with unsupported size")
+ }
+}
+
+func readIntLE(b []byte, size uintptr) uint64 {
+ switch size {
+ case 1:
+ return uint64(b[0])
+ case 2:
+ _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
+ return uint64(b[0]) | uint64(b[1])<<8
+ case 4:
+ _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
+ return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
+ case 8:
+ _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
+ return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
+ uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
+ default:
+ panic("syscall: readInt with unsupported size")
+ }
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names. It returns the number of
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
+ origlen := len(buf)
+ count = 0
+ for max != 0 && len(buf) > 0 {
+ reclen, ok := direntReclen(buf)
+ if !ok || reclen > uint64(len(buf)) {
+ return origlen, count, names
+ }
+ rec := buf[:reclen]
+ buf = buf[reclen:]
+ ino, ok := direntIno(rec)
+ if !ok {
+ break
+ }
+ if ino == 0 { // File absent in directory.
+ continue
+ }
+ const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
+ namlen, ok := direntNamlen(rec)
+ if !ok || namoff+namlen > uint64(len(rec)) {
+ break
+ }
+ name := rec[namoff : namoff+namlen]
+ for i, c := range name {
+ if c == 0 {
+ name = name[:i]
+ break
+ }
+ }
+ // Check for useless names before allocating a string.
+ if string(name) == "." || string(name) == ".." {
+ continue
+ }
+ max--
+ count++
+ names = append(names, string(name))
+ }
+ return origlen - len(buf), count, names
+}
diff --git a/vendor/golang.org/x/sys/unix/endian_big.go b/vendor/golang.org/x/sys/unix/endian_big.go
new file mode 100644
index 0000000..a520265
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/endian_big.go
@@ -0,0 +1,10 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+//
+//go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64
+// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64
+
+package unix
+
+const isBigEndian = true
diff --git a/vendor/golang.org/x/sys/unix/endian_little.go b/vendor/golang.org/x/sys/unix/endian_little.go
new file mode 100644
index 0000000..b0f2bc4
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/endian_little.go
@@ -0,0 +1,10 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+//
+//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh
+// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh
+
+package unix
+
+const isBigEndian = false
diff --git a/vendor/golang.org/x/sys/unix/env_unix.go b/vendor/golang.org/x/sys/unix/env_unix.go
new file mode 100644
index 0000000..29ccc4d
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/env_unix.go
@@ -0,0 +1,32 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
+
+// Unix environment variables.
+
+package unix
+
+import "syscall"
+
+func Getenv(key string) (value string, found bool) {
+ return syscall.Getenv(key)
+}
+
+func Setenv(key, value string) error {
+ return syscall.Setenv(key, value)
+}
+
+func Clearenv() {
+ syscall.Clearenv()
+}
+
+func Environ() []string {
+ return syscall.Environ()
+}
+
+func Unsetenv(key string) error {
+ return syscall.Unsetenv(key)
+}
diff --git a/vendor/golang.org/x/sys/unix/epoll_zos.go b/vendor/golang.org/x/sys/unix/epoll_zos.go
new file mode 100644
index 0000000..cedaf7e
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/epoll_zos.go
@@ -0,0 +1,221 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build zos && s390x
+// +build zos,s390x
+
+package unix
+
+import (
+ "sync"
+)
+
+// This file simulates epoll on z/OS using poll.
+
+// Analogous to epoll_event on Linux.
+// TODO(neeilan): Pad is because the Linux kernel expects a 96-bit struct. We never pass this to the kernel; remove?
+type EpollEvent struct {
+ Events uint32
+ Fd int32
+ Pad int32
+}
+
+const (
+ EPOLLERR = 0x8
+ EPOLLHUP = 0x10
+ EPOLLIN = 0x1
+ EPOLLMSG = 0x400
+ EPOLLOUT = 0x4
+ EPOLLPRI = 0x2
+ EPOLLRDBAND = 0x80
+ EPOLLRDNORM = 0x40
+ EPOLLWRBAND = 0x200
+ EPOLLWRNORM = 0x100
+ EPOLL_CTL_ADD = 0x1
+ EPOLL_CTL_DEL = 0x2
+ EPOLL_CTL_MOD = 0x3
+ // The following constants are part of the epoll API, but represent
+ // currently unsupported functionality on z/OS.
+ // EPOLL_CLOEXEC = 0x80000
+ // EPOLLET = 0x80000000
+ // EPOLLONESHOT = 0x40000000
+ // EPOLLRDHUP = 0x2000 // Typically used with edge-triggered notis
+ // EPOLLEXCLUSIVE = 0x10000000 // Exclusive wake-up mode
+ // EPOLLWAKEUP = 0x20000000 // Relies on Linux's BLOCK_SUSPEND capability
+)
+
+// TODO(neeilan): We can eliminate these epToPoll / pToEpoll calls by using identical mask values for POLL/EPOLL
+// constants where possible The lower 16 bits of epoll events (uint32) can fit any system poll event (int16).
+
+// epToPollEvt converts epoll event field to poll equivalent.
+// In epoll, Events is a 32-bit field, while poll uses 16 bits.
+func epToPollEvt(events uint32) int16 {
+ var ep2p = map[uint32]int16{
+ EPOLLIN: POLLIN,
+ EPOLLOUT: POLLOUT,
+ EPOLLHUP: POLLHUP,
+ EPOLLPRI: POLLPRI,
+ EPOLLERR: POLLERR,
+ }
+
+ var pollEvts int16 = 0
+ for epEvt, pEvt := range ep2p {
+ if (events & epEvt) != 0 {
+ pollEvts |= pEvt
+ }
+ }
+
+ return pollEvts
+}
+
+// pToEpollEvt converts 16 bit poll event bitfields to 32-bit epoll event fields.
+func pToEpollEvt(revents int16) uint32 {
+ var p2ep = map[int16]uint32{
+ POLLIN: EPOLLIN,
+ POLLOUT: EPOLLOUT,
+ POLLHUP: EPOLLHUP,
+ POLLPRI: EPOLLPRI,
+ POLLERR: EPOLLERR,
+ }
+
+ var epollEvts uint32 = 0
+ for pEvt, epEvt := range p2ep {
+ if (revents & pEvt) != 0 {
+ epollEvts |= epEvt
+ }
+ }
+
+ return epollEvts
+}
+
+// Per-process epoll implementation.
+type epollImpl struct {
+ mu sync.Mutex
+ epfd2ep map[int]*eventPoll
+ nextEpfd int
+}
+
+// eventPoll holds a set of file descriptors being watched by the process. A process can have multiple epoll instances.
+// On Linux, this is an in-kernel data structure accessed through a fd.
+type eventPoll struct {
+ mu sync.Mutex
+ fds map[int]*EpollEvent
+}
+
+// epoll impl for this process.
+var impl epollImpl = epollImpl{
+ epfd2ep: make(map[int]*eventPoll),
+ nextEpfd: 0,
+}
+
+func (e *epollImpl) epollcreate(size int) (epfd int, err error) {
+ e.mu.Lock()
+ defer e.mu.Unlock()
+ epfd = e.nextEpfd
+ e.nextEpfd++
+
+ e.epfd2ep[epfd] = &eventPoll{
+ fds: make(map[int]*EpollEvent),
+ }
+ return epfd, nil
+}
+
+func (e *epollImpl) epollcreate1(flag int) (fd int, err error) {
+ return e.epollcreate(4)
+}
+
+func (e *epollImpl) epollctl(epfd int, op int, fd int, event *EpollEvent) (err error) {
+ e.mu.Lock()
+ defer e.mu.Unlock()
+
+ ep, ok := e.epfd2ep[epfd]
+ if !ok {
+
+ return EBADF
+ }
+
+ switch op {
+ case EPOLL_CTL_ADD:
+ // TODO(neeilan): When we make epfds and fds disjoint, detect epoll
+ // loops here (instances watching each other) and return ELOOP.
+ if _, ok := ep.fds[fd]; ok {
+ return EEXIST
+ }
+ ep.fds[fd] = event
+ case EPOLL_CTL_MOD:
+ if _, ok := ep.fds[fd]; !ok {
+ return ENOENT
+ }
+ ep.fds[fd] = event
+ case EPOLL_CTL_DEL:
+ if _, ok := ep.fds[fd]; !ok {
+ return ENOENT
+ }
+ delete(ep.fds, fd)
+
+ }
+ return nil
+}
+
+// Must be called while holding ep.mu
+func (ep *eventPoll) getFds() []int {
+ fds := make([]int, len(ep.fds))
+ for fd := range ep.fds {
+ fds = append(fds, fd)
+ }
+ return fds
+}
+
+func (e *epollImpl) epollwait(epfd int, events []EpollEvent, msec int) (n int, err error) {
+ e.mu.Lock() // in [rare] case of concurrent epollcreate + epollwait
+ ep, ok := e.epfd2ep[epfd]
+
+ if !ok {
+ e.mu.Unlock()
+ return 0, EBADF
+ }
+
+ pollfds := make([]PollFd, 4)
+ for fd, epollevt := range ep.fds {
+ pollfds = append(pollfds, PollFd{Fd: int32(fd), Events: epToPollEvt(epollevt.Events)})
+ }
+ e.mu.Unlock()
+
+ n, err = Poll(pollfds, msec)
+ if err != nil {
+ return n, err
+ }
+
+ i := 0
+ for _, pFd := range pollfds {
+ if pFd.Revents != 0 {
+ events[i] = EpollEvent{Fd: pFd.Fd, Events: pToEpollEvt(pFd.Revents)}
+ i++
+ }
+
+ if i == n {
+ break
+ }
+ }
+
+ return n, nil
+}
+
+func EpollCreate(size int) (fd int, err error) {
+ return impl.epollcreate(size)
+}
+
+func EpollCreate1(flag int) (fd int, err error) {
+ return impl.epollcreate1(flag)
+}
+
+func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
+ return impl.epollctl(epfd, op, fd, event)
+}
+
+// Because EpollWait mutates events, the caller is expected to coordinate
+// concurrent access if calling with the same epfd from multiple goroutines.
+func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
+ return impl.epollwait(epfd, events, msec)
+}
diff --git a/vendor/golang.org/x/sys/unix/errors_freebsd_386.go b/vendor/golang.org/x/sys/unix/errors_freebsd_386.go
new file mode 100644
index 0000000..761db66
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/errors_freebsd_386.go
@@ -0,0 +1,233 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
+// them here for backwards compatibility.
+
+package unix
+
+const (
+ DLT_HHDLC = 0x79
+ IFF_SMART = 0x20
+ IFT_1822 = 0x2
+ IFT_A12MPPSWITCH = 0x82
+ IFT_AAL2 = 0xbb
+ IFT_AAL5 = 0x31
+ IFT_ADSL = 0x5e
+ IFT_AFLANE8023 = 0x3b
+ IFT_AFLANE8025 = 0x3c
+ IFT_ARAP = 0x58
+ IFT_ARCNET = 0x23
+ IFT_ARCNETPLUS = 0x24
+ IFT_ASYNC = 0x54
+ IFT_ATM = 0x25
+ IFT_ATMDXI = 0x69
+ IFT_ATMFUNI = 0x6a
+ IFT_ATMIMA = 0x6b
+ IFT_ATMLOGICAL = 0x50
+ IFT_ATMRADIO = 0xbd
+ IFT_ATMSUBINTERFACE = 0x86
+ IFT_ATMVCIENDPT = 0xc2
+ IFT_ATMVIRTUAL = 0x95
+ IFT_BGPPOLICYACCOUNTING = 0xa2
+ IFT_BSC = 0x53
+ IFT_CCTEMUL = 0x3d
+ IFT_CEPT = 0x13
+ IFT_CES = 0x85
+ IFT_CHANNEL = 0x46
+ IFT_CNR = 0x55
+ IFT_COFFEE = 0x84
+ IFT_COMPOSITELINK = 0x9b
+ IFT_DCN = 0x8d
+ IFT_DIGITALPOWERLINE = 0x8a
+ IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
+ IFT_DLSW = 0x4a
+ IFT_DOCSCABLEDOWNSTREAM = 0x80
+ IFT_DOCSCABLEMACLAYER = 0x7f
+ IFT_DOCSCABLEUPSTREAM = 0x81
+ IFT_DS0 = 0x51
+ IFT_DS0BUNDLE = 0x52
+ IFT_DS1FDL = 0xaa
+ IFT_DS3 = 0x1e
+ IFT_DTM = 0x8c
+ IFT_DVBASILN = 0xac
+ IFT_DVBASIOUT = 0xad
+ IFT_DVBRCCDOWNSTREAM = 0x93
+ IFT_DVBRCCMACLAYER = 0x92
+ IFT_DVBRCCUPSTREAM = 0x94
+ IFT_ENC = 0xf4
+ IFT_EON = 0x19
+ IFT_EPLRS = 0x57
+ IFT_ESCON = 0x49
+ IFT_ETHER = 0x6
+ IFT_FAITH = 0xf2
+ IFT_FAST = 0x7d
+ IFT_FASTETHER = 0x3e
+ IFT_FASTETHERFX = 0x45
+ IFT_FDDI = 0xf
+ IFT_FIBRECHANNEL = 0x38
+ IFT_FRAMERELAYINTERCONNECT = 0x3a
+ IFT_FRAMERELAYMPI = 0x5c
+ IFT_FRDLCIENDPT = 0xc1
+ IFT_FRELAY = 0x20
+ IFT_FRELAYDCE = 0x2c
+ IFT_FRF16MFRBUNDLE = 0xa3
+ IFT_FRFORWARD = 0x9e
+ IFT_G703AT2MB = 0x43
+ IFT_G703AT64K = 0x42
+ IFT_GIF = 0xf0
+ IFT_GIGABITETHERNET = 0x75
+ IFT_GR303IDT = 0xb2
+ IFT_GR303RDT = 0xb1
+ IFT_H323GATEKEEPER = 0xa4
+ IFT_H323PROXY = 0xa5
+ IFT_HDH1822 = 0x3
+ IFT_HDLC = 0x76
+ IFT_HDSL2 = 0xa8
+ IFT_HIPERLAN2 = 0xb7
+ IFT_HIPPI = 0x2f
+ IFT_HIPPIINTERFACE = 0x39
+ IFT_HOSTPAD = 0x5a
+ IFT_HSSI = 0x2e
+ IFT_HY = 0xe
+ IFT_IBM370PARCHAN = 0x48
+ IFT_IDSL = 0x9a
+ IFT_IEEE80211 = 0x47
+ IFT_IEEE80212 = 0x37
+ IFT_IEEE8023ADLAG = 0xa1
+ IFT_IFGSN = 0x91
+ IFT_IMT = 0xbe
+ IFT_INTERLEAVE = 0x7c
+ IFT_IP = 0x7e
+ IFT_IPFORWARD = 0x8e
+ IFT_IPOVERATM = 0x72
+ IFT_IPOVERCDLC = 0x6d
+ IFT_IPOVERCLAW = 0x6e
+ IFT_IPSWITCH = 0x4e
+ IFT_IPXIP = 0xf9
+ IFT_ISDN = 0x3f
+ IFT_ISDNBASIC = 0x14
+ IFT_ISDNPRIMARY = 0x15
+ IFT_ISDNS = 0x4b
+ IFT_ISDNU = 0x4c
+ IFT_ISO88022LLC = 0x29
+ IFT_ISO88023 = 0x7
+ IFT_ISO88024 = 0x8
+ IFT_ISO88025 = 0x9
+ IFT_ISO88025CRFPINT = 0x62
+ IFT_ISO88025DTR = 0x56
+ IFT_ISO88025FIBER = 0x73
+ IFT_ISO88026 = 0xa
+ IFT_ISUP = 0xb3
+ IFT_L3IPXVLAN = 0x89
+ IFT_LAPB = 0x10
+ IFT_LAPD = 0x4d
+ IFT_LAPF = 0x77
+ IFT_LOCALTALK = 0x2a
+ IFT_LOOP = 0x18
+ IFT_MEDIAMAILOVERIP = 0x8b
+ IFT_MFSIGLINK = 0xa7
+ IFT_MIOX25 = 0x26
+ IFT_MODEM = 0x30
+ IFT_MPC = 0x71
+ IFT_MPLS = 0xa6
+ IFT_MPLSTUNNEL = 0x96
+ IFT_MSDSL = 0x8f
+ IFT_MVL = 0xbf
+ IFT_MYRINET = 0x63
+ IFT_NFAS = 0xaf
+ IFT_NSIP = 0x1b
+ IFT_OPTICALCHANNEL = 0xc3
+ IFT_OPTICALTRANSPORT = 0xc4
+ IFT_OTHER = 0x1
+ IFT_P10 = 0xc
+ IFT_P80 = 0xd
+ IFT_PARA = 0x22
+ IFT_PFLOG = 0xf6
+ IFT_PFSYNC = 0xf7
+ IFT_PLC = 0xae
+ IFT_POS = 0xab
+ IFT_PPPMULTILINKBUNDLE = 0x6c
+ IFT_PROPBWAP2MP = 0xb8
+ IFT_PROPCNLS = 0x59
+ IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
+ IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
+ IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
+ IFT_PROPMUX = 0x36
+ IFT_PROPWIRELESSP2P = 0x9d
+ IFT_PTPSERIAL = 0x16
+ IFT_PVC = 0xf1
+ IFT_QLLC = 0x44
+ IFT_RADIOMAC = 0xbc
+ IFT_RADSL = 0x5f
+ IFT_REACHDSL = 0xc0
+ IFT_RFC1483 = 0x9f
+ IFT_RS232 = 0x21
+ IFT_RSRB = 0x4f
+ IFT_SDLC = 0x11
+ IFT_SDSL = 0x60
+ IFT_SHDSL = 0xa9
+ IFT_SIP = 0x1f
+ IFT_SLIP = 0x1c
+ IFT_SMDSDXI = 0x2b
+ IFT_SMDSICIP = 0x34
+ IFT_SONET = 0x27
+ IFT_SONETOVERHEADCHANNEL = 0xb9
+ IFT_SONETPATH = 0x32
+ IFT_SONETVT = 0x33
+ IFT_SRP = 0x97
+ IFT_SS7SIGLINK = 0x9c
+ IFT_STACKTOSTACK = 0x6f
+ IFT_STARLAN = 0xb
+ IFT_STF = 0xd7
+ IFT_T1 = 0x12
+ IFT_TDLC = 0x74
+ IFT_TERMPAD = 0x5b
+ IFT_TR008 = 0xb0
+ IFT_TRANSPHDLC = 0x7b
+ IFT_TUNNEL = 0x83
+ IFT_ULTRA = 0x1d
+ IFT_USB = 0xa0
+ IFT_V11 = 0x40
+ IFT_V35 = 0x2d
+ IFT_V36 = 0x41
+ IFT_V37 = 0x78
+ IFT_VDSL = 0x61
+ IFT_VIRTUALIPADDRESS = 0x70
+ IFT_VOICEEM = 0x64
+ IFT_VOICEENCAP = 0x67
+ IFT_VOICEFXO = 0x65
+ IFT_VOICEFXS = 0x66
+ IFT_VOICEOVERATM = 0x98
+ IFT_VOICEOVERFRAMERELAY = 0x99
+ IFT_VOICEOVERIP = 0x68
+ IFT_X213 = 0x5d
+ IFT_X25 = 0x5
+ IFT_X25DDN = 0x4
+ IFT_X25HUNTGROUP = 0x7a
+ IFT_X25MLP = 0x79
+ IFT_X25PLE = 0x28
+ IFT_XETHER = 0x1a
+ IPPROTO_MAXID = 0x34
+ IPV6_FAITH = 0x1d
+ IPV6_MIN_MEMBERSHIPS = 0x1f
+ IP_FAITH = 0x16
+ IP_MAX_SOURCE_FILTER = 0x400
+ IP_MIN_MEMBERSHIPS = 0x1f
+ MAP_NORESERVE = 0x40
+ MAP_RENAME = 0x20
+ NET_RT_MAXID = 0x6
+ RTF_PRCLONING = 0x10000
+ RTM_OLDADD = 0x9
+ RTM_OLDDEL = 0xa
+ RT_CACHING_CONTEXT = 0x1
+ RT_NORTREF = 0x2
+ SIOCADDRT = 0x8030720a
+ SIOCALIFADDR = 0x8118691b
+ SIOCDELRT = 0x8030720b
+ SIOCDLIFADDR = 0x8118691d
+ SIOCGLIFADDR = 0xc118691c
+ SIOCGLIFPHYADDR = 0xc118694b
+ SIOCSLIFPHYADDR = 0x8118694a
+)
diff --git a/vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
new file mode 100644
index 0000000..070f44b
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
@@ -0,0 +1,233 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
+// them here for backwards compatibility.
+
+package unix
+
+const (
+ DLT_HHDLC = 0x79
+ IFF_SMART = 0x20
+ IFT_1822 = 0x2
+ IFT_A12MPPSWITCH = 0x82
+ IFT_AAL2 = 0xbb
+ IFT_AAL5 = 0x31
+ IFT_ADSL = 0x5e
+ IFT_AFLANE8023 = 0x3b
+ IFT_AFLANE8025 = 0x3c
+ IFT_ARAP = 0x58
+ IFT_ARCNET = 0x23
+ IFT_ARCNETPLUS = 0x24
+ IFT_ASYNC = 0x54
+ IFT_ATM = 0x25
+ IFT_ATMDXI = 0x69
+ IFT_ATMFUNI = 0x6a
+ IFT_ATMIMA = 0x6b
+ IFT_ATMLOGICAL = 0x50
+ IFT_ATMRADIO = 0xbd
+ IFT_ATMSUBINTERFACE = 0x86
+ IFT_ATMVCIENDPT = 0xc2
+ IFT_ATMVIRTUAL = 0x95
+ IFT_BGPPOLICYACCOUNTING = 0xa2
+ IFT_BSC = 0x53
+ IFT_CCTEMUL = 0x3d
+ IFT_CEPT = 0x13
+ IFT_CES = 0x85
+ IFT_CHANNEL = 0x46
+ IFT_CNR = 0x55
+ IFT_COFFEE = 0x84
+ IFT_COMPOSITELINK = 0x9b
+ IFT_DCN = 0x8d
+ IFT_DIGITALPOWERLINE = 0x8a
+ IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
+ IFT_DLSW = 0x4a
+ IFT_DOCSCABLEDOWNSTREAM = 0x80
+ IFT_DOCSCABLEMACLAYER = 0x7f
+ IFT_DOCSCABLEUPSTREAM = 0x81
+ IFT_DS0 = 0x51
+ IFT_DS0BUNDLE = 0x52
+ IFT_DS1FDL = 0xaa
+ IFT_DS3 = 0x1e
+ IFT_DTM = 0x8c
+ IFT_DVBASILN = 0xac
+ IFT_DVBASIOUT = 0xad
+ IFT_DVBRCCDOWNSTREAM = 0x93
+ IFT_DVBRCCMACLAYER = 0x92
+ IFT_DVBRCCUPSTREAM = 0x94
+ IFT_ENC = 0xf4
+ IFT_EON = 0x19
+ IFT_EPLRS = 0x57
+ IFT_ESCON = 0x49
+ IFT_ETHER = 0x6
+ IFT_FAITH = 0xf2
+ IFT_FAST = 0x7d
+ IFT_FASTETHER = 0x3e
+ IFT_FASTETHERFX = 0x45
+ IFT_FDDI = 0xf
+ IFT_FIBRECHANNEL = 0x38
+ IFT_FRAMERELAYINTERCONNECT = 0x3a
+ IFT_FRAMERELAYMPI = 0x5c
+ IFT_FRDLCIENDPT = 0xc1
+ IFT_FRELAY = 0x20
+ IFT_FRELAYDCE = 0x2c
+ IFT_FRF16MFRBUNDLE = 0xa3
+ IFT_FRFORWARD = 0x9e
+ IFT_G703AT2MB = 0x43
+ IFT_G703AT64K = 0x42
+ IFT_GIF = 0xf0
+ IFT_GIGABITETHERNET = 0x75
+ IFT_GR303IDT = 0xb2
+ IFT_GR303RDT = 0xb1
+ IFT_H323GATEKEEPER = 0xa4
+ IFT_H323PROXY = 0xa5
+ IFT_HDH1822 = 0x3
+ IFT_HDLC = 0x76
+ IFT_HDSL2 = 0xa8
+ IFT_HIPERLAN2 = 0xb7
+ IFT_HIPPI = 0x2f
+ IFT_HIPPIINTERFACE = 0x39
+ IFT_HOSTPAD = 0x5a
+ IFT_HSSI = 0x2e
+ IFT_HY = 0xe
+ IFT_IBM370PARCHAN = 0x48
+ IFT_IDSL = 0x9a
+ IFT_IEEE80211 = 0x47
+ IFT_IEEE80212 = 0x37
+ IFT_IEEE8023ADLAG = 0xa1
+ IFT_IFGSN = 0x91
+ IFT_IMT = 0xbe
+ IFT_INTERLEAVE = 0x7c
+ IFT_IP = 0x7e
+ IFT_IPFORWARD = 0x8e
+ IFT_IPOVERATM = 0x72
+ IFT_IPOVERCDLC = 0x6d
+ IFT_IPOVERCLAW = 0x6e
+ IFT_IPSWITCH = 0x4e
+ IFT_IPXIP = 0xf9
+ IFT_ISDN = 0x3f
+ IFT_ISDNBASIC = 0x14
+ IFT_ISDNPRIMARY = 0x15
+ IFT_ISDNS = 0x4b
+ IFT_ISDNU = 0x4c
+ IFT_ISO88022LLC = 0x29
+ IFT_ISO88023 = 0x7
+ IFT_ISO88024 = 0x8
+ IFT_ISO88025 = 0x9
+ IFT_ISO88025CRFPINT = 0x62
+ IFT_ISO88025DTR = 0x56
+ IFT_ISO88025FIBER = 0x73
+ IFT_ISO88026 = 0xa
+ IFT_ISUP = 0xb3
+ IFT_L3IPXVLAN = 0x89
+ IFT_LAPB = 0x10
+ IFT_LAPD = 0x4d
+ IFT_LAPF = 0x77
+ IFT_LOCALTALK = 0x2a
+ IFT_LOOP = 0x18
+ IFT_MEDIAMAILOVERIP = 0x8b
+ IFT_MFSIGLINK = 0xa7
+ IFT_MIOX25 = 0x26
+ IFT_MODEM = 0x30
+ IFT_MPC = 0x71
+ IFT_MPLS = 0xa6
+ IFT_MPLSTUNNEL = 0x96
+ IFT_MSDSL = 0x8f
+ IFT_MVL = 0xbf
+ IFT_MYRINET = 0x63
+ IFT_NFAS = 0xaf
+ IFT_NSIP = 0x1b
+ IFT_OPTICALCHANNEL = 0xc3
+ IFT_OPTICALTRANSPORT = 0xc4
+ IFT_OTHER = 0x1
+ IFT_P10 = 0xc
+ IFT_P80 = 0xd
+ IFT_PARA = 0x22
+ IFT_PFLOG = 0xf6
+ IFT_PFSYNC = 0xf7
+ IFT_PLC = 0xae
+ IFT_POS = 0xab
+ IFT_PPPMULTILINKBUNDLE = 0x6c
+ IFT_PROPBWAP2MP = 0xb8
+ IFT_PROPCNLS = 0x59
+ IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
+ IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
+ IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
+ IFT_PROPMUX = 0x36
+ IFT_PROPWIRELESSP2P = 0x9d
+ IFT_PTPSERIAL = 0x16
+ IFT_PVC = 0xf1
+ IFT_QLLC = 0x44
+ IFT_RADIOMAC = 0xbc
+ IFT_RADSL = 0x5f
+ IFT_REACHDSL = 0xc0
+ IFT_RFC1483 = 0x9f
+ IFT_RS232 = 0x21
+ IFT_RSRB = 0x4f
+ IFT_SDLC = 0x11
+ IFT_SDSL = 0x60
+ IFT_SHDSL = 0xa9
+ IFT_SIP = 0x1f
+ IFT_SLIP = 0x1c
+ IFT_SMDSDXI = 0x2b
+ IFT_SMDSICIP = 0x34
+ IFT_SONET = 0x27
+ IFT_SONETOVERHEADCHANNEL = 0xb9
+ IFT_SONETPATH = 0x32
+ IFT_SONETVT = 0x33
+ IFT_SRP = 0x97
+ IFT_SS7SIGLINK = 0x9c
+ IFT_STACKTOSTACK = 0x6f
+ IFT_STARLAN = 0xb
+ IFT_STF = 0xd7
+ IFT_T1 = 0x12
+ IFT_TDLC = 0x74
+ IFT_TERMPAD = 0x5b
+ IFT_TR008 = 0xb0
+ IFT_TRANSPHDLC = 0x7b
+ IFT_TUNNEL = 0x83
+ IFT_ULTRA = 0x1d
+ IFT_USB = 0xa0
+ IFT_V11 = 0x40
+ IFT_V35 = 0x2d
+ IFT_V36 = 0x41
+ IFT_V37 = 0x78
+ IFT_VDSL = 0x61
+ IFT_VIRTUALIPADDRESS = 0x70
+ IFT_VOICEEM = 0x64
+ IFT_VOICEENCAP = 0x67
+ IFT_VOICEFXO = 0x65
+ IFT_VOICEFXS = 0x66
+ IFT_VOICEOVERATM = 0x98
+ IFT_VOICEOVERFRAMERELAY = 0x99
+ IFT_VOICEOVERIP = 0x68
+ IFT_X213 = 0x5d
+ IFT_X25 = 0x5
+ IFT_X25DDN = 0x4
+ IFT_X25HUNTGROUP = 0x7a
+ IFT_X25MLP = 0x79
+ IFT_X25PLE = 0x28
+ IFT_XETHER = 0x1a
+ IPPROTO_MAXID = 0x34
+ IPV6_FAITH = 0x1d
+ IPV6_MIN_MEMBERSHIPS = 0x1f
+ IP_FAITH = 0x16
+ IP_MAX_SOURCE_FILTER = 0x400
+ IP_MIN_MEMBERSHIPS = 0x1f
+ MAP_NORESERVE = 0x40
+ MAP_RENAME = 0x20
+ NET_RT_MAXID = 0x6
+ RTF_PRCLONING = 0x10000
+ RTM_OLDADD = 0x9
+ RTM_OLDDEL = 0xa
+ RT_CACHING_CONTEXT = 0x1
+ RT_NORTREF = 0x2
+ SIOCADDRT = 0x8040720a
+ SIOCALIFADDR = 0x8118691b
+ SIOCDELRT = 0x8040720b
+ SIOCDLIFADDR = 0x8118691d
+ SIOCGLIFADDR = 0xc118691c
+ SIOCGLIFPHYADDR = 0xc118694b
+ SIOCSLIFPHYADDR = 0x8118694a
+)
diff --git a/vendor/golang.org/x/sys/unix/errors_freebsd_arm.go b/vendor/golang.org/x/sys/unix/errors_freebsd_arm.go
new file mode 100644
index 0000000..856dca3
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/errors_freebsd_arm.go
@@ -0,0 +1,226 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+const (
+ IFT_1822 = 0x2
+ IFT_A12MPPSWITCH = 0x82
+ IFT_AAL2 = 0xbb
+ IFT_AAL5 = 0x31
+ IFT_ADSL = 0x5e
+ IFT_AFLANE8023 = 0x3b
+ IFT_AFLANE8025 = 0x3c
+ IFT_ARAP = 0x58
+ IFT_ARCNET = 0x23
+ IFT_ARCNETPLUS = 0x24
+ IFT_ASYNC = 0x54
+ IFT_ATM = 0x25
+ IFT_ATMDXI = 0x69
+ IFT_ATMFUNI = 0x6a
+ IFT_ATMIMA = 0x6b
+ IFT_ATMLOGICAL = 0x50
+ IFT_ATMRADIO = 0xbd
+ IFT_ATMSUBINTERFACE = 0x86
+ IFT_ATMVCIENDPT = 0xc2
+ IFT_ATMVIRTUAL = 0x95
+ IFT_BGPPOLICYACCOUNTING = 0xa2
+ IFT_BSC = 0x53
+ IFT_CCTEMUL = 0x3d
+ IFT_CEPT = 0x13
+ IFT_CES = 0x85
+ IFT_CHANNEL = 0x46
+ IFT_CNR = 0x55
+ IFT_COFFEE = 0x84
+ IFT_COMPOSITELINK = 0x9b
+ IFT_DCN = 0x8d
+ IFT_DIGITALPOWERLINE = 0x8a
+ IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
+ IFT_DLSW = 0x4a
+ IFT_DOCSCABLEDOWNSTREAM = 0x80
+ IFT_DOCSCABLEMACLAYER = 0x7f
+ IFT_DOCSCABLEUPSTREAM = 0x81
+ IFT_DS0 = 0x51
+ IFT_DS0BUNDLE = 0x52
+ IFT_DS1FDL = 0xaa
+ IFT_DS3 = 0x1e
+ IFT_DTM = 0x8c
+ IFT_DVBASILN = 0xac
+ IFT_DVBASIOUT = 0xad
+ IFT_DVBRCCDOWNSTREAM = 0x93
+ IFT_DVBRCCMACLAYER = 0x92
+ IFT_DVBRCCUPSTREAM = 0x94
+ IFT_ENC = 0xf4
+ IFT_EON = 0x19
+ IFT_EPLRS = 0x57
+ IFT_ESCON = 0x49
+ IFT_ETHER = 0x6
+ IFT_FAST = 0x7d
+ IFT_FASTETHER = 0x3e
+ IFT_FASTETHERFX = 0x45
+ IFT_FDDI = 0xf
+ IFT_FIBRECHANNEL = 0x38
+ IFT_FRAMERELAYINTERCONNECT = 0x3a
+ IFT_FRAMERELAYMPI = 0x5c
+ IFT_FRDLCIENDPT = 0xc1
+ IFT_FRELAY = 0x20
+ IFT_FRELAYDCE = 0x2c
+ IFT_FRF16MFRBUNDLE = 0xa3
+ IFT_FRFORWARD = 0x9e
+ IFT_G703AT2MB = 0x43
+ IFT_G703AT64K = 0x42
+ IFT_GIF = 0xf0
+ IFT_GIGABITETHERNET = 0x75
+ IFT_GR303IDT = 0xb2
+ IFT_GR303RDT = 0xb1
+ IFT_H323GATEKEEPER = 0xa4
+ IFT_H323PROXY = 0xa5
+ IFT_HDH1822 = 0x3
+ IFT_HDLC = 0x76
+ IFT_HDSL2 = 0xa8
+ IFT_HIPERLAN2 = 0xb7
+ IFT_HIPPI = 0x2f
+ IFT_HIPPIINTERFACE = 0x39
+ IFT_HOSTPAD = 0x5a
+ IFT_HSSI = 0x2e
+ IFT_HY = 0xe
+ IFT_IBM370PARCHAN = 0x48
+ IFT_IDSL = 0x9a
+ IFT_IEEE80211 = 0x47
+ IFT_IEEE80212 = 0x37
+ IFT_IEEE8023ADLAG = 0xa1
+ IFT_IFGSN = 0x91
+ IFT_IMT = 0xbe
+ IFT_INTERLEAVE = 0x7c
+ IFT_IP = 0x7e
+ IFT_IPFORWARD = 0x8e
+ IFT_IPOVERATM = 0x72
+ IFT_IPOVERCDLC = 0x6d
+ IFT_IPOVERCLAW = 0x6e
+ IFT_IPSWITCH = 0x4e
+ IFT_ISDN = 0x3f
+ IFT_ISDNBASIC = 0x14
+ IFT_ISDNPRIMARY = 0x15
+ IFT_ISDNS = 0x4b
+ IFT_ISDNU = 0x4c
+ IFT_ISO88022LLC = 0x29
+ IFT_ISO88023 = 0x7
+ IFT_ISO88024 = 0x8
+ IFT_ISO88025 = 0x9
+ IFT_ISO88025CRFPINT = 0x62
+ IFT_ISO88025DTR = 0x56
+ IFT_ISO88025FIBER = 0x73
+ IFT_ISO88026 = 0xa
+ IFT_ISUP = 0xb3
+ IFT_L3IPXVLAN = 0x89
+ IFT_LAPB = 0x10
+ IFT_LAPD = 0x4d
+ IFT_LAPF = 0x77
+ IFT_LOCALTALK = 0x2a
+ IFT_LOOP = 0x18
+ IFT_MEDIAMAILOVERIP = 0x8b
+ IFT_MFSIGLINK = 0xa7
+ IFT_MIOX25 = 0x26
+ IFT_MODEM = 0x30
+ IFT_MPC = 0x71
+ IFT_MPLS = 0xa6
+ IFT_MPLSTUNNEL = 0x96
+ IFT_MSDSL = 0x8f
+ IFT_MVL = 0xbf
+ IFT_MYRINET = 0x63
+ IFT_NFAS = 0xaf
+ IFT_NSIP = 0x1b
+ IFT_OPTICALCHANNEL = 0xc3
+ IFT_OPTICALTRANSPORT = 0xc4
+ IFT_OTHER = 0x1
+ IFT_P10 = 0xc
+ IFT_P80 = 0xd
+ IFT_PARA = 0x22
+ IFT_PFLOG = 0xf6
+ IFT_PFSYNC = 0xf7
+ IFT_PLC = 0xae
+ IFT_POS = 0xab
+ IFT_PPPMULTILINKBUNDLE = 0x6c
+ IFT_PROPBWAP2MP = 0xb8
+ IFT_PROPCNLS = 0x59
+ IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
+ IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
+ IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
+ IFT_PROPMUX = 0x36
+ IFT_PROPWIRELESSP2P = 0x9d
+ IFT_PTPSERIAL = 0x16
+ IFT_PVC = 0xf1
+ IFT_QLLC = 0x44
+ IFT_RADIOMAC = 0xbc
+ IFT_RADSL = 0x5f
+ IFT_REACHDSL = 0xc0
+ IFT_RFC1483 = 0x9f
+ IFT_RS232 = 0x21
+ IFT_RSRB = 0x4f
+ IFT_SDLC = 0x11
+ IFT_SDSL = 0x60
+ IFT_SHDSL = 0xa9
+ IFT_SIP = 0x1f
+ IFT_SLIP = 0x1c
+ IFT_SMDSDXI = 0x2b
+ IFT_SMDSICIP = 0x34
+ IFT_SONET = 0x27
+ IFT_SONETOVERHEADCHANNEL = 0xb9
+ IFT_SONETPATH = 0x32
+ IFT_SONETVT = 0x33
+ IFT_SRP = 0x97
+ IFT_SS7SIGLINK = 0x9c
+ IFT_STACKTOSTACK = 0x6f
+ IFT_STARLAN = 0xb
+ IFT_STF = 0xd7
+ IFT_T1 = 0x12
+ IFT_TDLC = 0x74
+ IFT_TERMPAD = 0x5b
+ IFT_TR008 = 0xb0
+ IFT_TRANSPHDLC = 0x7b
+ IFT_TUNNEL = 0x83
+ IFT_ULTRA = 0x1d
+ IFT_USB = 0xa0
+ IFT_V11 = 0x40
+ IFT_V35 = 0x2d
+ IFT_V36 = 0x41
+ IFT_V37 = 0x78
+ IFT_VDSL = 0x61
+ IFT_VIRTUALIPADDRESS = 0x70
+ IFT_VOICEEM = 0x64
+ IFT_VOICEENCAP = 0x67
+ IFT_VOICEFXO = 0x65
+ IFT_VOICEFXS = 0x66
+ IFT_VOICEOVERATM = 0x98
+ IFT_VOICEOVERFRAMERELAY = 0x99
+ IFT_VOICEOVERIP = 0x68
+ IFT_X213 = 0x5d
+ IFT_X25 = 0x5
+ IFT_X25DDN = 0x4
+ IFT_X25HUNTGROUP = 0x7a
+ IFT_X25MLP = 0x79
+ IFT_X25PLE = 0x28
+ IFT_XETHER = 0x1a
+
+ // missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go
+ IFF_SMART = 0x20
+ IFT_FAITH = 0xf2
+ IFT_IPXIP = 0xf9
+ IPPROTO_MAXID = 0x34
+ IPV6_FAITH = 0x1d
+ IP_FAITH = 0x16
+ MAP_NORESERVE = 0x40
+ MAP_RENAME = 0x20
+ NET_RT_MAXID = 0x6
+ RTF_PRCLONING = 0x10000
+ RTM_OLDADD = 0x9
+ RTM_OLDDEL = 0xa
+ SIOCADDRT = 0x8030720a
+ SIOCALIFADDR = 0x8118691b
+ SIOCDELRT = 0x8030720b
+ SIOCDLIFADDR = 0x8118691d
+ SIOCGLIFADDR = 0xc118691c
+ SIOCGLIFPHYADDR = 0xc118694b
+ SIOCSLIFPHYADDR = 0x8118694a
+)
diff --git a/vendor/golang.org/x/sys/unix/errors_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/errors_freebsd_arm64.go
new file mode 100644
index 0000000..946dcf3
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/errors_freebsd_arm64.go
@@ -0,0 +1,17 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
+// them here for backwards compatibility.
+
+package unix
+
+const (
+ DLT_HHDLC = 0x79
+ IPV6_MIN_MEMBERSHIPS = 0x1f
+ IP_MAX_SOURCE_FILTER = 0x400
+ IP_MIN_MEMBERSHIPS = 0x1f
+ RT_CACHING_CONTEXT = 0x1
+ RT_NORTREF = 0x2
+)
diff --git a/vendor/golang.org/x/sys/unix/fcntl.go b/vendor/golang.org/x/sys/unix/fcntl.go
new file mode 100644
index 0000000..e9b9912
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/fcntl.go
@@ -0,0 +1,37 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build dragonfly || freebsd || linux || netbsd || openbsd
+// +build dragonfly freebsd linux netbsd openbsd
+
+package unix
+
+import "unsafe"
+
+// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
+// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.
+var fcntl64Syscall uintptr = SYS_FCNTL
+
+func fcntl(fd int, cmd, arg int) (int, error) {
+ valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
+ var err error
+ if errno != 0 {
+ err = errno
+ }
+ return int(valptr), err
+}
+
+// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
+func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
+ return fcntl(int(fd), cmd, arg)
+}
+
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
+ _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
+ if errno == 0 {
+ return nil
+ }
+ return errno
+}
diff --git a/vendor/golang.org/x/sys/unix/fcntl_darwin.go b/vendor/golang.org/x/sys/unix/fcntl_darwin.go
new file mode 100644
index 0000000..a9911c7
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/fcntl_darwin.go
@@ -0,0 +1,24 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+import "unsafe"
+
+// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
+func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
+ return fcntl(int(fd), cmd, arg)
+}
+
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
+ _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
+ return err
+}
+
+// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command.
+func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error {
+ _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore))))
+ return err
+}
diff --git a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
new file mode 100644
index 0000000..29d4480
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
@@ -0,0 +1,14 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc)
+// +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc
+
+package unix
+
+func init() {
+ // On 32-bit Linux systems, the fcntl syscall that matches Go's
+ // Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
+ fcntl64Syscall = SYS_FCNTL64
+}
diff --git a/vendor/golang.org/x/sys/unix/fdset.go b/vendor/golang.org/x/sys/unix/fdset.go
new file mode 100644
index 0000000..a8068f9
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/fdset.go
@@ -0,0 +1,30 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
+
+package unix
+
+// Set adds fd to the set fds.
+func (fds *FdSet) Set(fd int) {
+ fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
+}
+
+// Clear removes fd from the set fds.
+func (fds *FdSet) Clear(fd int) {
+ fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
+}
+
+// IsSet returns whether fd is in the set fds.
+func (fds *FdSet) IsSet(fd int) bool {
+ return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
+}
+
+// Zero clears the set fds.
+func (fds *FdSet) Zero() {
+ for i := range fds.Bits {
+ fds.Bits[i] = 0
+ }
+}
diff --git a/vendor/golang.org/x/sys/unix/fstatfs_zos.go b/vendor/golang.org/x/sys/unix/fstatfs_zos.go
new file mode 100644
index 0000000..e377cc9
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/fstatfs_zos.go
@@ -0,0 +1,164 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build zos && s390x
+// +build zos,s390x
+
+package unix
+
+import (
+ "unsafe"
+)
+
+// This file simulates fstatfs on z/OS using fstatvfs and w_getmntent.
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ var stat_v Statvfs_t
+ err = Fstatvfs(fd, &stat_v)
+ if err == nil {
+ // populate stat
+ stat.Type = 0
+ stat.Bsize = stat_v.Bsize
+ stat.Blocks = stat_v.Blocks
+ stat.Bfree = stat_v.Bfree
+ stat.Bavail = stat_v.Bavail
+ stat.Files = stat_v.Files
+ stat.Ffree = stat_v.Ffree
+ stat.Fsid = stat_v.Fsid
+ stat.Namelen = stat_v.Namemax
+ stat.Frsize = stat_v.Frsize
+ stat.Flags = stat_v.Flag
+ for passn := 0; passn < 5; passn++ {
+ switch passn {
+ case 0:
+ err = tryGetmntent64(stat)
+ break
+ case 1:
+ err = tryGetmntent128(stat)
+ break
+ case 2:
+ err = tryGetmntent256(stat)
+ break
+ case 3:
+ err = tryGetmntent512(stat)
+ break
+ case 4:
+ err = tryGetmntent1024(stat)
+ break
+ default:
+ break
+ }
+ //proceed to return if: err is nil (found), err is nonnil but not ERANGE (another error occurred)
+ if err == nil || err != nil && err != ERANGE {
+ break
+ }
+ }
+ }
+ return err
+}
+
+func tryGetmntent64(stat *Statfs_t) (err error) {
+ var mnt_ent_buffer struct {
+ header W_Mnth
+ filesys_info [64]W_Mntent
+ }
+ var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
+ fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
+ if err != nil {
+ return err
+ }
+ err = ERANGE //return ERANGE if no match is found in this batch
+ for i := 0; i < fs_count; i++ {
+ if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
+ stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
+ err = nil
+ break
+ }
+ }
+ return err
+}
+
+func tryGetmntent128(stat *Statfs_t) (err error) {
+ var mnt_ent_buffer struct {
+ header W_Mnth
+ filesys_info [128]W_Mntent
+ }
+ var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
+ fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
+ if err != nil {
+ return err
+ }
+ err = ERANGE //return ERANGE if no match is found in this batch
+ for i := 0; i < fs_count; i++ {
+ if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
+ stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
+ err = nil
+ break
+ }
+ }
+ return err
+}
+
+func tryGetmntent256(stat *Statfs_t) (err error) {
+ var mnt_ent_buffer struct {
+ header W_Mnth
+ filesys_info [256]W_Mntent
+ }
+ var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
+ fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
+ if err != nil {
+ return err
+ }
+ err = ERANGE //return ERANGE if no match is found in this batch
+ for i := 0; i < fs_count; i++ {
+ if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
+ stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
+ err = nil
+ break
+ }
+ }
+ return err
+}
+
+func tryGetmntent512(stat *Statfs_t) (err error) {
+ var mnt_ent_buffer struct {
+ header W_Mnth
+ filesys_info [512]W_Mntent
+ }
+ var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
+ fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
+ if err != nil {
+ return err
+ }
+ err = ERANGE //return ERANGE if no match is found in this batch
+ for i := 0; i < fs_count; i++ {
+ if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
+ stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
+ err = nil
+ break
+ }
+ }
+ return err
+}
+
+func tryGetmntent1024(stat *Statfs_t) (err error) {
+ var mnt_ent_buffer struct {
+ header W_Mnth
+ filesys_info [1024]W_Mntent
+ }
+ var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer))
+ fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size)
+ if err != nil {
+ return err
+ }
+ err = ERANGE //return ERANGE if no match is found in this batch
+ for i := 0; i < fs_count; i++ {
+ if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) {
+ stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0])
+ err = nil
+ break
+ }
+ }
+ return err
+}
diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go
new file mode 100644
index 0000000..0dee232
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/gccgo.go
@@ -0,0 +1,60 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gccgo && !aix
+// +build gccgo,!aix
+
+package unix
+
+import "syscall"
+
+// We can't use the gc-syntax .s files for gccgo. On the plus side
+// much of the functionality can be written directly in Go.
+
+func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
+
+func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
+
+func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
+ syscall.Entersyscall()
+ r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
+ syscall.Exitsyscall()
+ return r, 0
+}
+
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ syscall.Entersyscall()
+ r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
+ syscall.Exitsyscall()
+ return r, 0, syscall.Errno(errno)
+}
+
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ syscall.Entersyscall()
+ r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
+ syscall.Exitsyscall()
+ return r, 0, syscall.Errno(errno)
+}
+
+func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ syscall.Entersyscall()
+ r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
+ syscall.Exitsyscall()
+ return r, 0, syscall.Errno(errno)
+}
+
+func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
+ r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
+ return r, 0
+}
+
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
+ return r, 0, syscall.Errno(errno)
+}
+
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
+ return r, 0, syscall.Errno(errno)
+}
diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c
new file mode 100644
index 0000000..2cb1fef
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/gccgo_c.c
@@ -0,0 +1,45 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo
+// +build !aix
+
+#include
+#include
+#include
+
+#define _STRINGIFY2_(x) #x
+#define _STRINGIFY_(x) _STRINGIFY2_(x)
+#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
+
+// Call syscall from C code because the gccgo support for calling from
+// Go to C does not support varargs functions.
+
+struct ret {
+ uintptr_t r;
+ uintptr_t err;
+};
+
+struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
+ __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall");
+
+struct ret
+gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
+{
+ struct ret r;
+
+ errno = 0;
+ r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+ r.err = errno;
+ return r;
+}
+
+uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
+ __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError");
+
+uintptr_t
+gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
+{
+ return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+}
diff --git a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
new file mode 100644
index 0000000..e60e49a
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
@@ -0,0 +1,21 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build gccgo && linux && amd64
+// +build gccgo,linux,amd64
+
+package unix
+
+import "syscall"
+
+//extern gettimeofday
+func realGettimeofday(*Timeval, *byte) int32
+
+func gettimeofday(tv *Timeval) (err syscall.Errno) {
+ r := realGettimeofday(tv, nil)
+ if r < 0 {
+ return syscall.GetErrno()
+ }
+ return 0
+}
diff --git a/vendor/golang.org/x/sys/unix/ifreq_linux.go b/vendor/golang.org/x/sys/unix/ifreq_linux.go
new file mode 100644
index 0000000..15721a5
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/ifreq_linux.go
@@ -0,0 +1,142 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build linux
+// +build linux
+
+package unix
+
+import (
+ "unsafe"
+)
+
+// Helpers for dealing with ifreq since it contains a union and thus requires a
+// lot of unsafe.Pointer casts to use properly.
+
+// An Ifreq is a type-safe wrapper around the raw ifreq struct. An Ifreq
+// contains an interface name and a union of arbitrary data which can be
+// accessed using the Ifreq's methods. To create an Ifreq, use the NewIfreq
+// function.
+//
+// Use the Name method to access the stored interface name. The union data
+// fields can be get and set using the following methods:
+// - Uint16/SetUint16: flags
+// - Uint32/SetUint32: ifindex, metric, mtu
+type Ifreq struct{ raw ifreq }
+
+// NewIfreq creates an Ifreq with the input network interface name after
+// validating the name does not exceed IFNAMSIZ-1 (trailing NULL required)
+// bytes.
+func NewIfreq(name string) (*Ifreq, error) {
+ // Leave room for terminating NULL byte.
+ if len(name) >= IFNAMSIZ {
+ return nil, EINVAL
+ }
+
+ var ifr ifreq
+ copy(ifr.Ifrn[:], name)
+
+ return &Ifreq{raw: ifr}, nil
+}
+
+// TODO(mdlayher): get/set methods for hardware address sockaddr, char array, etc.
+
+// Name returns the interface name associated with the Ifreq.
+func (ifr *Ifreq) Name() string {
+ return ByteSliceToString(ifr.raw.Ifrn[:])
+}
+
+// According to netdevice(7), only AF_INET addresses are returned for numerous
+// sockaddr ioctls. For convenience, we expose these as Inet4Addr since the Port
+// field and other data is always empty.
+
+// Inet4Addr returns the Ifreq union data from an embedded sockaddr as a C
+// in_addr/Go []byte (4-byte IPv4 address) value. If the sockaddr family is not
+// AF_INET, an error is returned.
+func (ifr *Ifreq) Inet4Addr() ([]byte, error) {
+ raw := *(*RawSockaddrInet4)(unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]))
+ if raw.Family != AF_INET {
+ // Cannot safely interpret raw.Addr bytes as an IPv4 address.
+ return nil, EINVAL
+ }
+
+ return raw.Addr[:], nil
+}
+
+// SetInet4Addr sets a C in_addr/Go []byte (4-byte IPv4 address) value in an
+// embedded sockaddr within the Ifreq's union data. v must be 4 bytes in length
+// or an error will be returned.
+func (ifr *Ifreq) SetInet4Addr(v []byte) error {
+ if len(v) != 4 {
+ return EINVAL
+ }
+
+ var addr [4]byte
+ copy(addr[:], v)
+
+ ifr.clear()
+ *(*RawSockaddrInet4)(
+ unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]),
+ ) = RawSockaddrInet4{
+ // Always set IP family as ioctls would require it anyway.
+ Family: AF_INET,
+ Addr: addr,
+ }
+
+ return nil
+}
+
+// Uint16 returns the Ifreq union data as a C short/Go uint16 value.
+func (ifr *Ifreq) Uint16() uint16 {
+ return *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0]))
+}
+
+// SetUint16 sets a C short/Go uint16 value as the Ifreq's union data.
+func (ifr *Ifreq) SetUint16(v uint16) {
+ ifr.clear()
+ *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0])) = v
+}
+
+// Uint32 returns the Ifreq union data as a C int/Go uint32 value.
+func (ifr *Ifreq) Uint32() uint32 {
+ return *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0]))
+}
+
+// SetUint32 sets a C int/Go uint32 value as the Ifreq's union data.
+func (ifr *Ifreq) SetUint32(v uint32) {
+ ifr.clear()
+ *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0])) = v
+}
+
+// clear zeroes the ifreq's union field to prevent trailing garbage data from
+// being sent to the kernel if an ifreq is reused.
+func (ifr *Ifreq) clear() {
+ for i := range ifr.raw.Ifru {
+ ifr.raw.Ifru[i] = 0
+ }
+}
+
+// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
+// IoctlGetEthtoolDrvinfo which use these APIs under the hood.
+
+// An ifreqData is an Ifreq which carries pointer data. To produce an ifreqData,
+// use the Ifreq.withData method.
+type ifreqData struct {
+ name [IFNAMSIZ]byte
+ // A type separate from ifreq is required in order to comply with the
+ // unsafe.Pointer rules since the "pointer-ness" of data would not be
+ // preserved if it were cast into the byte array of a raw ifreq.
+ data unsafe.Pointer
+ // Pad to the same size as ifreq.
+ _ [len(ifreq{}.Ifru) - SizeofPtr]byte
+}
+
+// withData produces an ifreqData with the pointer p set for ioctls which require
+// arbitrary pointer data.
+func (ifr Ifreq) withData(p unsafe.Pointer) ifreqData {
+ return ifreqData{
+ name: ifr.raw.Ifrn,
+ data: p,
+ }
+}
diff --git a/vendor/golang.org/x/sys/unix/ioctl.go b/vendor/golang.org/x/sys/unix/ioctl.go
new file mode 100644
index 0000000..6c7ad05
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/ioctl.go
@@ -0,0 +1,75 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package unix
+
+import (
+ "runtime"
+ "unsafe"
+)
+
+// ioctl itself should not be exposed directly, but additional get/set
+// functions for specific types are permissible.
+
+// IoctlSetInt performs an ioctl operation which sets an integer value
+// on fd, using the specified request number.
+func IoctlSetInt(fd int, req uint, value int) error {
+ return ioctl(fd, req, uintptr(value))
+}
+
+// IoctlSetPointerInt performs an ioctl operation which sets an
+// integer value on fd, using the specified request number. The ioctl
+// argument is called with a pointer to the integer value, rather than
+// passing the integer value directly.
+func IoctlSetPointerInt(fd int, req uint, value int) error {
+ v := int32(value)
+ return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
+}
+
+// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
+//
+// To change fd's window size, the req argument should be TIOCSWINSZ.
+func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
+ // TODO: if we get the chance, remove the req parameter and
+ // hardcode TIOCSWINSZ.
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+ runtime.KeepAlive(value)
+ return err
+}
+
+// IoctlSetTermios performs an ioctl on fd with a *Termios.
+//
+// The req value will usually be TCSETA or TIOCSETA.
+func IoctlSetTermios(fd int, req uint, value *Termios) error {
+ // TODO: if we get the chance, remove the req parameter.
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+ runtime.KeepAlive(value)
+ return err
+}
+
+// IoctlGetInt performs an ioctl operation which gets an integer value
+// from fd, using the specified request number.
+//
+// A few ioctl requests use the return value as an output parameter;
+// for those, IoctlRetInt should be used instead of this function.
+func IoctlGetInt(fd int, req uint) (int, error) {
+ var value int
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return value, err
+}
+
+func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
+ var value Winsize
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return &value, err
+}
+
+func IoctlGetTermios(fd int, req uint) (*Termios, error) {
+ var value Termios
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return &value, err
+}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_linux.go b/vendor/golang.org/x/sys/unix/ioctl_linux.go
new file mode 100644
index 0000000..884430b
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/ioctl_linux.go
@@ -0,0 +1,219 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+import (
+ "unsafe"
+)
+
+// IoctlRetInt performs an ioctl operation specified by req on a device
+// associated with opened file descriptor fd, and returns a non-negative
+// integer that is returned by the ioctl syscall.
+func IoctlRetInt(fd int, req uint) (int, error) {
+ ret, _, err := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), 0)
+ if err != 0 {
+ return 0, err
+ }
+ return int(ret), nil
+}
+
+func IoctlGetUint32(fd int, req uint) (uint32, error) {
+ var value uint32
+ err := ioctlPtr(fd, req, unsafe.Pointer(&value))
+ return value, err
+}
+
+func IoctlGetRTCTime(fd int) (*RTCTime, error) {
+ var value RTCTime
+ err := ioctlPtr(fd, RTC_RD_TIME, unsafe.Pointer(&value))
+ return &value, err
+}
+
+func IoctlSetRTCTime(fd int, value *RTCTime) error {
+ return ioctlPtr(fd, RTC_SET_TIME, unsafe.Pointer(value))
+}
+
+func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
+ var value RTCWkAlrm
+ err := ioctlPtr(fd, RTC_WKALM_RD, unsafe.Pointer(&value))
+ return &value, err
+}
+
+func IoctlSetRTCWkAlrm(fd int, value *RTCWkAlrm) error {
+ return ioctlPtr(fd, RTC_WKALM_SET, unsafe.Pointer(value))
+}
+
+// IoctlGetEthtoolDrvinfo fetches ethtool driver information for the network
+// device specified by ifname.
+func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
+ ifr, err := NewIfreq(ifname)
+ if err != nil {
+ return nil, err
+ }
+
+ value := EthtoolDrvinfo{Cmd: ETHTOOL_GDRVINFO}
+ ifrd := ifr.withData(unsafe.Pointer(&value))
+
+ err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
+ return &value, err
+}
+
+// IoctlGetWatchdogInfo fetches information about a watchdog device from the
+// Linux watchdog API. For more information, see:
+// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
+func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
+ var value WatchdogInfo
+ err := ioctlPtr(fd, WDIOC_GETSUPPORT, unsafe.Pointer(&value))
+ return &value, err
+}
+
+// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
+// more information, see:
+// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
+func IoctlWatchdogKeepalive(fd int) error {
+ // arg is ignored and not a pointer, so ioctl is fine instead of ioctlPtr.
+ return ioctl(fd, WDIOC_KEEPALIVE, 0)
+}
+
+// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
+// range of data conveyed in value to the file associated with the file
+// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
+func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
+ return ioctlPtr(destFd, FICLONERANGE, unsafe.Pointer(value))
+}
+
+// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
+// associated with the file description srcFd to the file associated with the
+// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
+func IoctlFileClone(destFd, srcFd int) error {
+ return ioctl(destFd, FICLONE, uintptr(srcFd))
+}
+
+type FileDedupeRange struct {
+ Src_offset uint64
+ Src_length uint64
+ Reserved1 uint16
+ Reserved2 uint32
+ Info []FileDedupeRangeInfo
+}
+
+type FileDedupeRangeInfo struct {
+ Dest_fd int64
+ Dest_offset uint64
+ Bytes_deduped uint64
+ Status int32
+ Reserved uint32
+}
+
+// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
+// range of data conveyed in value from the file associated with the file
+// descriptor srcFd to the value.Info destinations. See the
+// ioctl_fideduperange(2) man page for details.
+func IoctlFileDedupeRange(srcFd int, value *FileDedupeRange) error {
+ buf := make([]byte, SizeofRawFileDedupeRange+
+ len(value.Info)*SizeofRawFileDedupeRangeInfo)
+ rawrange := (*RawFileDedupeRange)(unsafe.Pointer(&buf[0]))
+ rawrange.Src_offset = value.Src_offset
+ rawrange.Src_length = value.Src_length
+ rawrange.Dest_count = uint16(len(value.Info))
+ rawrange.Reserved1 = value.Reserved1
+ rawrange.Reserved2 = value.Reserved2
+
+ for i := range value.Info {
+ rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
+ uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
+ uintptr(i*SizeofRawFileDedupeRangeInfo)))
+ rawinfo.Dest_fd = value.Info[i].Dest_fd
+ rawinfo.Dest_offset = value.Info[i].Dest_offset
+ rawinfo.Bytes_deduped = value.Info[i].Bytes_deduped
+ rawinfo.Status = value.Info[i].Status
+ rawinfo.Reserved = value.Info[i].Reserved
+ }
+
+ err := ioctlPtr(srcFd, FIDEDUPERANGE, unsafe.Pointer(&buf[0]))
+
+ // Output
+ for i := range value.Info {
+ rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
+ uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
+ uintptr(i*SizeofRawFileDedupeRangeInfo)))
+ value.Info[i].Dest_fd = rawinfo.Dest_fd
+ value.Info[i].Dest_offset = rawinfo.Dest_offset
+ value.Info[i].Bytes_deduped = rawinfo.Bytes_deduped
+ value.Info[i].Status = rawinfo.Status
+ value.Info[i].Reserved = rawinfo.Reserved
+ }
+
+ return err
+}
+
+func IoctlHIDGetDesc(fd int, value *HIDRawReportDescriptor) error {
+ return ioctlPtr(fd, HIDIOCGRDESC, unsafe.Pointer(value))
+}
+
+func IoctlHIDGetRawInfo(fd int) (*HIDRawDevInfo, error) {
+ var value HIDRawDevInfo
+ err := ioctlPtr(fd, HIDIOCGRAWINFO, unsafe.Pointer(&value))
+ return &value, err
+}
+
+func IoctlHIDGetRawName(fd int) (string, error) {
+ var value [_HIDIOCGRAWNAME_LEN]byte
+ err := ioctlPtr(fd, _HIDIOCGRAWNAME, unsafe.Pointer(&value[0]))
+ return ByteSliceToString(value[:]), err
+}
+
+func IoctlHIDGetRawPhys(fd int) (string, error) {
+ var value [_HIDIOCGRAWPHYS_LEN]byte
+ err := ioctlPtr(fd, _HIDIOCGRAWPHYS, unsafe.Pointer(&value[0]))
+ return ByteSliceToString(value[:]), err
+}
+
+func IoctlHIDGetRawUniq(fd int) (string, error) {
+ var value [_HIDIOCGRAWUNIQ_LEN]byte
+ err := ioctlPtr(fd, _HIDIOCGRAWUNIQ, unsafe.Pointer(&value[0]))
+ return ByteSliceToString(value[:]), err
+}
+
+// IoctlIfreq performs an ioctl using an Ifreq structure for input and/or
+// output. See the netdevice(7) man page for details.
+func IoctlIfreq(fd int, req uint, value *Ifreq) error {
+ // It is possible we will add more fields to *Ifreq itself later to prevent
+ // misuse, so pass the raw *ifreq directly.
+ return ioctlPtr(fd, req, unsafe.Pointer(&value.raw))
+}
+
+// TODO(mdlayher): export if and when IfreqData is exported.
+
+// ioctlIfreqData performs an ioctl using an ifreqData structure for input
+// and/or output. See the netdevice(7) man page for details.
+func ioctlIfreqData(fd int, req uint, value *ifreqData) error {
+ // The memory layout of IfreqData (type-safe) and ifreq (not type-safe) are
+ // identical so pass *IfreqData directly.
+ return ioctlPtr(fd, req, unsafe.Pointer(value))
+}
+
+// IoctlKCMClone attaches a new file descriptor to a multiplexor by cloning an
+// existing KCM socket, returning a structure containing the file descriptor of
+// the new socket.
+func IoctlKCMClone(fd int) (*KCMClone, error) {
+ var info KCMClone
+ if err := ioctlPtr(fd, SIOCKCMCLONE, unsafe.Pointer(&info)); err != nil {
+ return nil, err
+ }
+
+ return &info, nil
+}
+
+// IoctlKCMAttach attaches a TCP socket and associated BPF program file
+// descriptor to a multiplexor.
+func IoctlKCMAttach(fd int, info KCMAttach) error {
+ return ioctlPtr(fd, SIOCKCMATTACH, unsafe.Pointer(&info))
+}
+
+// IoctlKCMUnattach unattaches a TCP socket file descriptor from a multiplexor.
+func IoctlKCMUnattach(fd int, info KCMUnattach) error {
+ return ioctlPtr(fd, SIOCKCMUNATTACH, unsafe.Pointer(&info))
+}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_zos.go b/vendor/golang.org/x/sys/unix/ioctl_zos.go
new file mode 100644
index 0000000..5384e7d
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/ioctl_zos.go
@@ -0,0 +1,74 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build zos && s390x
+// +build zos,s390x
+
+package unix
+
+import (
+ "runtime"
+ "unsafe"
+)
+
+// ioctl itself should not be exposed directly, but additional get/set
+// functions for specific types are permissible.
+
+// IoctlSetInt performs an ioctl operation which sets an integer value
+// on fd, using the specified request number.
+func IoctlSetInt(fd int, req uint, value int) error {
+ return ioctl(fd, req, uintptr(value))
+}
+
+// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
+//
+// To change fd's window size, the req argument should be TIOCSWINSZ.
+func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
+ // TODO: if we get the chance, remove the req parameter and
+ // hardcode TIOCSWINSZ.
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+ runtime.KeepAlive(value)
+ return err
+}
+
+// IoctlSetTermios performs an ioctl on fd with a *Termios.
+//
+// The req value is expected to be TCSETS, TCSETSW, or TCSETSF
+func IoctlSetTermios(fd int, req uint, value *Termios) error {
+ if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
+ return ENOSYS
+ }
+ err := Tcsetattr(fd, int(req), value)
+ runtime.KeepAlive(value)
+ return err
+}
+
+// IoctlGetInt performs an ioctl operation which gets an integer value
+// from fd, using the specified request number.
+//
+// A few ioctl requests use the return value as an output parameter;
+// for those, IoctlRetInt should be used instead of this function.
+func IoctlGetInt(fd int, req uint) (int, error) {
+ var value int
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return value, err
+}
+
+func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
+ var value Winsize
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ return &value, err
+}
+
+// IoctlGetTermios performs an ioctl on fd with a *Termios.
+//
+// The req value is expected to be TCGETS
+func IoctlGetTermios(fd int, req uint) (*Termios, error) {
+ var value Termios
+ if req != TCGETS {
+ return &value, ENOSYS
+ }
+ err := Tcgetattr(fd, &value)
+ return &value, err
+}
diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh
new file mode 100644
index 0000000..ee73623
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/mkall.sh
@@ -0,0 +1,231 @@
+#!/usr/bin/env bash
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# This script runs or (given -n) prints suggested commands to generate files for
+# the Architecture/OS specified by the GOARCH and GOOS environment variables.
+# See README.md for more information about how the build system works.
+
+GOOSARCH="${GOOS}_${GOARCH}"
+
+# defaults
+mksyscall="go run mksyscall.go"
+mkerrors="./mkerrors.sh"
+zerrors="zerrors_$GOOSARCH.go"
+mksysctl=""
+zsysctl="zsysctl_$GOOSARCH.go"
+mksysnum=
+mktypes=
+mkasm=
+run="sh"
+cmd=""
+
+case "$1" in
+-syscalls)
+ for i in zsyscall*go
+ do
+ # Run the command line that appears in the first line
+ # of the generated file to regenerate it.
+ sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
+ rm _$i
+ done
+ exit 0
+ ;;
+-n)
+ run="cat"
+ cmd="echo"
+ shift
+esac
+
+case "$#" in
+0)
+ ;;
+*)
+ echo 'usage: mkall.sh [-n]' 1>&2
+ exit 2
+esac
+
+if [[ "$GOOS" = "linux" ]]; then
+ # Use the Docker-based build system
+ # Files generated through docker (use $cmd so you can Ctl-C the build or run)
+ $cmd docker build --tag generate:$GOOS $GOOS
+ $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && /bin/pwd):/build generate:$GOOS
+ exit
+fi
+
+GOOSARCH_in=syscall_$GOOSARCH.go
+case "$GOOSARCH" in
+_* | *_ | _)
+ echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
+ exit 1
+ ;;
+aix_ppc)
+ mkerrors="$mkerrors -maix32"
+ mksyscall="go run mksyscall_aix_ppc.go -aix"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+aix_ppc64)
+ mkerrors="$mkerrors -maix64"
+ mksyscall="go run mksyscall_aix_ppc64.go -aix"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+darwin_amd64)
+ mkerrors="$mkerrors -m64"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ mkasm="go run mkasm_darwin.go"
+ ;;
+darwin_arm64)
+ mkerrors="$mkerrors -m64"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ mkasm="go run mkasm_darwin.go"
+ ;;
+dragonfly_amd64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="go run mksyscall.go -dragonfly"
+ mksysnum="go run mksysnum.go 'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+freebsd_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="go run mksyscall.go -l32"
+ mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+freebsd_amd64)
+ mkerrors="$mkerrors -m64"
+ mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+freebsd_arm)
+ mkerrors="$mkerrors"
+ mksyscall="go run mksyscall.go -l32 -arm"
+ mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
+ # Let the type of C char be signed for making the bare syscall
+ # API consistent across platforms.
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+freebsd_arm64)
+ mkerrors="$mkerrors -m64"
+ mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+netbsd_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="go run mksyscall.go -l32 -netbsd"
+ mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+netbsd_amd64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="go run mksyscall.go -netbsd"
+ mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+netbsd_arm)
+ mkerrors="$mkerrors"
+ mksyscall="go run mksyscall.go -l32 -netbsd -arm"
+ mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
+ # Let the type of C char be signed for making the bare syscall
+ # API consistent across platforms.
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+netbsd_arm64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="go run mksyscall.go -netbsd"
+ mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+openbsd_386)
+ mkerrors="$mkerrors -m32"
+ mksyscall="go run mksyscall.go -l32 -openbsd"
+ mksysctl="go run mksysctl_openbsd.go"
+ mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+openbsd_amd64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="go run mksyscall.go -openbsd"
+ mksysctl="go run mksysctl_openbsd.go"
+ mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+openbsd_arm)
+ mkerrors="$mkerrors"
+ mksyscall="go run mksyscall.go -l32 -openbsd -arm"
+ mksysctl="go run mksysctl_openbsd.go"
+ mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
+ # Let the type of C char be signed for making the bare syscall
+ # API consistent across platforms.
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+openbsd_arm64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="go run mksyscall.go -openbsd"
+ mksysctl="go run mksysctl_openbsd.go"
+ mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
+ # Let the type of C char be signed for making the bare syscall
+ # API consistent across platforms.
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+openbsd_mips64)
+ mkerrors="$mkerrors -m64"
+ mksyscall="go run mksyscall.go -openbsd"
+ mksysctl="go run mksysctl_openbsd.go"
+ mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
+ # Let the type of C char be signed for making the bare syscall
+ # API consistent across platforms.
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+ ;;
+solaris_amd64)
+ mksyscall="go run mksyscall_solaris.go"
+ mkerrors="$mkerrors -m64"
+ mksysnum=
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+illumos_amd64)
+ mksyscall="go run mksyscall_solaris.go"
+ mkerrors=
+ mksysnum=
+ mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ ;;
+*)
+ echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
+ exit 1
+ ;;
+esac
+
+(
+ if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
+ case "$GOOS" in
+ *)
+ syscall_goos="syscall_$GOOS.go"
+ case "$GOOS" in
+ darwin | dragonfly | freebsd | netbsd | openbsd)
+ syscall_goos="syscall_bsd.go $syscall_goos"
+ ;;
+ esac
+ if [ -n "$mksyscall" ]; then
+ if [ "$GOOSARCH" == "aix_ppc64" ]; then
+ # aix/ppc64 script generates files instead of writing to stdin.
+ echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
+ elif [ "$GOOS" == "darwin" ]; then
+ # 1.12 and later, syscalls via libSystem
+ echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
+ # 1.13 and later, syscalls via libSystem (including syscallPtr)
+ echo "$mksyscall -tags $GOOS,$GOARCH,go1.13 syscall_darwin.1_13.go |gofmt >zsyscall_$GOOSARCH.1_13.go";
+ elif [ "$GOOS" == "illumos" ]; then
+ # illumos code generation requires a --illumos switch
+ echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go";
+ # illumos implies solaris, so solaris code generation is also required
+ echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go";
+ else
+ echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
+ fi
+ fi
+ esac
+ if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
+ if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
+ if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
+ if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
+) | $run
diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh
new file mode 100644
index 0000000..d888fb7
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/mkerrors.sh
@@ -0,0 +1,772 @@
+#!/usr/bin/env bash
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# Generate Go code listing errors and other #defined constant
+# values (ENAMETOOLONG etc.), by asking the preprocessor
+# about the definitions.
+
+unset LANG
+export LC_ALL=C
+export LC_CTYPE=C
+
+if test -z "$GOARCH" -o -z "$GOOS"; then
+ echo 1>&2 "GOARCH or GOOS not defined in environment"
+ exit 1
+fi
+
+# Check that we are using the new build system if we should
+if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
+ echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
+ echo 1>&2 "See README.md"
+ exit 1
+fi
+
+if [[ "$GOOS" = "aix" ]]; then
+ CC=${CC:-gcc}
+else
+ CC=${CC:-cc}
+fi
+
+if [[ "$GOOS" = "solaris" ]]; then
+ # Assumes GNU versions of utilities in PATH.
+ export PATH=/usr/gnu/bin:$PATH
+fi
+
+uname=$(uname)
+
+includes_AIX='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define AF_LOCAL AF_UNIX
+'
+
+includes_Darwin='
+#define _DARWIN_C_SOURCE
+#define KERNEL 1
+#define _DARWIN_USE_64_BIT_INODE
+#define __APPLE_USE_RFC_3542
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// for backwards compatibility because moved TIOCREMOTE to Kernel.framework after MacOSX12.0.sdk.
+#define TIOCREMOTE 0x80047469
+'
+
+includes_DragonFly='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+'
+
+includes_FreeBSD='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#if __FreeBSD__ >= 10
+#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10
+#undef SIOCAIFADDR
+#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data
+#undef SIOCSIFPHYADDR
+#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data
+#endif
+'
+
+includes_Linux='
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+#ifndef __LP64__
+#define _FILE_OFFSET_BITS 64
+#endif
+#define _GNU_SOURCE
+
+// is broken on powerpc64, as it fails to include definitions of
+// these structures. We just include them copied from .
+#if defined(__powerpc__)
+struct sgttyb {
+ char sg_ispeed;
+ char sg_ospeed;
+ char sg_erase;
+ char sg_kill;
+ short sg_flags;
+};
+
+struct tchars {
+ char t_intrc;
+ char t_quitc;
+ char t_startc;
+ char t_stopc;
+ char t_eofc;
+ char t_brkc;
+};
+
+struct ltchars {
+ char t_suspc;
+ char t_dsuspc;
+ char t_rprntc;
+ char t_flushc;
+ char t_werasc;
+ char t_lnextc;
+};
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#if defined(__sparc__)
+// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
+// definition in glibc. As only the error constants are needed here, include the
+// generic termibits.h (which is included by termbits.h on sparc).
+#include
+#else
+#include
+#endif
+
+#ifndef MSG_FASTOPEN
+#define MSG_FASTOPEN 0x20000000
+#endif
+
+#ifndef PTRACE_GETREGS
+#define PTRACE_GETREGS 0xc
+#endif
+
+#ifndef PTRACE_SETREGS
+#define PTRACE_SETREGS 0xd
+#endif
+
+#ifndef SOL_NETLINK
+#define SOL_NETLINK 270
+#endif
+
+#ifdef SOL_BLUETOOTH
+// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
+// but it is already in bluetooth_linux.go
+#undef SOL_BLUETOOTH
+#endif
+
+// Certain constants are missing from the fs/crypto UAPI
+#define FS_KEY_DESC_PREFIX "fscrypt:"
+#define FS_KEY_DESC_PREFIX_SIZE 8
+#define FS_MAX_KEY_SIZE 64
+
+// The code generator produces -0x1 for (~0), but an unsigned value is necessary
+// for the tipc_subscr timeout __u32 field.
+#undef TIPC_WAIT_FOREVER
+#define TIPC_WAIT_FOREVER 0xffffffff
+
+// Copied from linux/l2tp.h
+// Including linux/l2tp.h here causes conflicts between linux/in.h
+// and netinet/in.h included via net/route.h above.
+#define IPPROTO_L2TP 115
+
+// Copied from linux/hid.h.
+// Keep in sync with the size of the referenced fields.
+#define _HIDIOCGRAWNAME_LEN 128 // sizeof_field(struct hid_device, name)
+#define _HIDIOCGRAWPHYS_LEN 64 // sizeof_field(struct hid_device, phys)
+#define _HIDIOCGRAWUNIQ_LEN 64 // sizeof_field(struct hid_device, uniq)
+
+#define _HIDIOCGRAWNAME HIDIOCGRAWNAME(_HIDIOCGRAWNAME_LEN)
+#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN)
+#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN)
+
+'
+
+includes_NetBSD='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// Needed since refers to it...
+#define schedppq 1
+'
+
+includes_OpenBSD='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// We keep some constants not supported in OpenBSD 5.5 and beyond for
+// the promise of compatibility.
+#define EMUL_ENABLED 0x1
+#define EMUL_NATIVE 0x2
+#define IPV6_FAITH 0x1d
+#define IPV6_OPTIONS 0x1
+#define IPV6_RTHDR_STRICT 0x1
+#define IPV6_SOCKOPT_RESERVED1 0x3
+#define SIOCGIFGENERIC 0xc020693a
+#define SIOCSIFGENERIC 0x80206939
+#define WALTSIG 0x4
+'
+
+includes_SunOS='
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+'
+
+
+includes='
+#include
+#include
+#include