initial commit [141.14.140.180,mike]
This commit is contained in:
commit
156bb18c91
50 files changed
+13466
No files matched your search
@@ -0,0 +1,435 @@
|
||||
// Package config reads and writes Ghostty config files while preserving
|
||||
// everything the editor does not touch: comments, blank lines, ordering and
|
||||
// formatting of untouched entries.
|
||||
package config
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Line is one line of a config file.
|
||||
type Line struct {
|
||||
Raw string // original text; regenerated when the entry changes
|
||||
Key string // empty for comments, blank lines and unparsable lines
|
||||
Value string // raw value text after '=', trimmed (quotes are kept)
|
||||
}
|
||||
|
||||
// IsEntry reports whether the line is a key/value entry.
|
||||
func (l Line) IsEntry() bool { return l.Key != "" }
|
||||
|
||||
// File is a parsed config file.
|
||||
type File struct {
|
||||
Path string
|
||||
Exists bool
|
||||
ModTime time.Time
|
||||
Lines []Line
|
||||
}
|
||||
|
||||
// Load reads path. A missing file yields an empty File that will be created
|
||||
// on save.
|
||||
func Load(path string) (*File, error) {
|
||||
f := &File{Path: path}
|
||||
data, err := os.ReadFile(path)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return f, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fi, err := os.Stat(path); err == nil {
|
||||
f.ModTime = fi.ModTime()
|
||||
}
|
||||
f.Exists = true
|
||||
f.Lines = Parse(data)
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// Parse splits config data into lines.
|
||||
func Parse(data []byte) []Line {
|
||||
text := strings.ReplaceAll(string(data), "\r\n", "\n")
|
||||
text = strings.TrimSuffix(text, "\n")
|
||||
if text == "" {
|
||||
return nil
|
||||
}
|
||||
parts := strings.Split(text, "\n")
|
||||
lines := make([]Line, len(parts))
|
||||
for i, raw := range parts {
|
||||
lines[i] = parseLine(raw)
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
||||
func parseLine(raw string) Line {
|
||||
l := Line{Raw: raw}
|
||||
t := strings.TrimSpace(raw)
|
||||
if t == "" || strings.HasPrefix(t, "#") {
|
||||
return l
|
||||
}
|
||||
key, value, found := strings.Cut(t, "=")
|
||||
key = strings.TrimSpace(key)
|
||||
if key == "" || strings.ContainsAny(key, " \t") {
|
||||
return l
|
||||
}
|
||||
l.Key = key
|
||||
if found {
|
||||
l.Value = strings.TrimSpace(value)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
// FormatLine renders a key/value entry.
|
||||
func FormatLine(key, value string) string {
|
||||
if value == "" {
|
||||
value = `""`
|
||||
} else if strings.TrimSpace(value) != value && !isQuoted(value) {
|
||||
value = `"` + value + `"`
|
||||
}
|
||||
return key + " = " + value
|
||||
}
|
||||
|
||||
func isQuoted(v string) bool {
|
||||
return len(v) >= 2 && v[0] == '"' && v[len(v)-1] == '"'
|
||||
}
|
||||
|
||||
func newEntry(key, value string) Line {
|
||||
return Line{Raw: FormatLine(key, value), Key: key, Value: value}
|
||||
}
|
||||
|
||||
// Clone returns a deep copy (used for undo snapshots).
|
||||
func (f *File) Clone() *File {
|
||||
c := *f
|
||||
c.Lines = append([]Line(nil), f.Lines...)
|
||||
return &c
|
||||
}
|
||||
|
||||
// Has reports whether key is set in the file.
|
||||
func (f *File) Has(key string) bool {
|
||||
for _, l := range f.Lines {
|
||||
if l.Key == key {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Get returns the effective (last) value of key.
|
||||
func (f *File) Get(key string) (string, bool) {
|
||||
for i := len(f.Lines) - 1; i >= 0; i-- {
|
||||
if f.Lines[i].Key == key {
|
||||
return f.Lines[i].Value, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// GetAll returns every value of key in file order.
|
||||
func (f *File) GetAll(key string) []string {
|
||||
var out []string
|
||||
for _, l := range f.Lines {
|
||||
if l.Key == key {
|
||||
out = append(out, l.Value)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Keys returns the distinct keys set in the file, in order of appearance.
|
||||
func (f *File) Keys() []string {
|
||||
var out []string
|
||||
seen := map[string]bool{}
|
||||
for _, l := range f.Lines {
|
||||
if l.Key != "" && !seen[l.Key] {
|
||||
seen[l.Key] = true
|
||||
out = append(out, l.Key)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Set assigns a single value. The first existing entry is updated in place
|
||||
// and any further entries for the key are removed; otherwise a new entry is
|
||||
// appended.
|
||||
func (f *File) Set(key, value string) {
|
||||
f.SetAll(key, []string{value})
|
||||
}
|
||||
|
||||
// SetAll replaces all entries of key with values while disturbing the file
|
||||
// as little as possible: entries whose value is unchanged stay where they
|
||||
// are (with their original formatting), changed entries are rewritten in
|
||||
// place, removed ones are dropped and additional ones are inserted after
|
||||
// the preceding entry of the same key. An empty slice removes the key.
|
||||
func (f *File) SetAll(key string, values []string) {
|
||||
if len(values) == 0 {
|
||||
f.Unset(key)
|
||||
return
|
||||
}
|
||||
var pos []int // line indexes of the existing entries
|
||||
var old []string
|
||||
for i, l := range f.Lines {
|
||||
if l.Key == key {
|
||||
pos = append(pos, i)
|
||||
old = append(old, l.Value)
|
||||
}
|
||||
}
|
||||
if len(pos) == 0 {
|
||||
at := f.insertPos()
|
||||
entries := make([]Line, len(values))
|
||||
for i, v := range values {
|
||||
entries[i] = newEntry(key, v)
|
||||
}
|
||||
f.Lines = append(f.Lines[:at:at], append(entries, f.Lines[at:]...)...)
|
||||
return
|
||||
}
|
||||
|
||||
replace := map[int]Line{} // line index -> new content
|
||||
remove := map[int]bool{} // line indexes to drop
|
||||
after := map[int][]Line{} // new entries to insert after a line index
|
||||
before := map[int][]Line{} // new entries to insert before a line index
|
||||
last := -1 // line index of the last kept/replaced entry
|
||||
var dels []int // pending deleted entries in the current gap
|
||||
var ins []string // pending inserted values in the current gap
|
||||
flushGap := func() {
|
||||
// Pair deletions with insertions as in-place edits.
|
||||
n := min(len(dels), len(ins))
|
||||
for k := 0; k < n; k++ {
|
||||
replace[pos[dels[k]]] = newEntry(key, ins[k])
|
||||
last = pos[dels[k]]
|
||||
}
|
||||
for _, d := range dels[n:] {
|
||||
remove[pos[d]] = true
|
||||
}
|
||||
for _, v := range ins[n:] {
|
||||
if last >= 0 {
|
||||
after[last] = append(after[last], newEntry(key, v))
|
||||
} else {
|
||||
before[pos[0]] = append(before[pos[0]], newEntry(key, v))
|
||||
}
|
||||
}
|
||||
dels, ins = nil, nil
|
||||
}
|
||||
for _, op := range diff(old, values) {
|
||||
switch op.kind {
|
||||
case opKeep:
|
||||
flushGap()
|
||||
last = pos[op.i]
|
||||
case opDel:
|
||||
dels = append(dels, op.i)
|
||||
case opIns:
|
||||
ins = append(ins, values[op.j])
|
||||
}
|
||||
}
|
||||
flushGap()
|
||||
|
||||
lines := make([]Line, 0, len(f.Lines)+len(values))
|
||||
for i, l := range f.Lines {
|
||||
lines = append(lines, before[i]...)
|
||||
switch {
|
||||
case remove[i]:
|
||||
case replace[i].Key != "":
|
||||
lines = append(lines, replace[i])
|
||||
default:
|
||||
lines = append(lines, l)
|
||||
}
|
||||
lines = append(lines, after[i]...)
|
||||
}
|
||||
f.Lines = lines
|
||||
}
|
||||
|
||||
// insertPos is where new keys are appended: after the last entry, so that
|
||||
// trailing comments stay at the end of the file.
|
||||
func (f *File) insertPos() int {
|
||||
for i := len(f.Lines) - 1; i >= 0; i-- {
|
||||
if f.Lines[i].IsEntry() {
|
||||
return i + 1
|
||||
}
|
||||
}
|
||||
return len(f.Lines)
|
||||
}
|
||||
|
||||
type opKind int
|
||||
|
||||
const (
|
||||
opKeep opKind = iota
|
||||
opDel
|
||||
opIns
|
||||
)
|
||||
|
||||
type diffOp struct {
|
||||
kind opKind
|
||||
i, j int // index into old (keep, del) and new (keep, ins)
|
||||
}
|
||||
|
||||
// diff computes a minimal edit script from a to b using the longest common
|
||||
// subsequence. Lists are short (at most a few hundred entries).
|
||||
func diff(a, b []string) []diffOp {
|
||||
m, n := len(a), len(b)
|
||||
lcs := make([][]int, m+1)
|
||||
for i := range lcs {
|
||||
lcs[i] = make([]int, n+1)
|
||||
}
|
||||
for i := m - 1; i >= 0; i-- {
|
||||
for j := n - 1; j >= 0; j-- {
|
||||
if a[i] == b[j] {
|
||||
lcs[i][j] = lcs[i+1][j+1] + 1
|
||||
} else {
|
||||
lcs[i][j] = max(lcs[i+1][j], lcs[i][j+1])
|
||||
}
|
||||
}
|
||||
}
|
||||
var ops []diffOp
|
||||
i, j := 0, 0
|
||||
for i < m && j < n {
|
||||
switch {
|
||||
case a[i] == b[j]:
|
||||
ops = append(ops, diffOp{opKeep, i, j})
|
||||
i++
|
||||
j++
|
||||
case lcs[i+1][j] >= lcs[i][j+1]:
|
||||
ops = append(ops, diffOp{opDel, i, j})
|
||||
i++
|
||||
default:
|
||||
ops = append(ops, diffOp{opIns, i, j})
|
||||
j++
|
||||
}
|
||||
}
|
||||
for ; i < m; i++ {
|
||||
ops = append(ops, diffOp{opDel, i, j})
|
||||
}
|
||||
for ; j < n; j++ {
|
||||
ops = append(ops, diffOp{opIns, i, j})
|
||||
}
|
||||
return ops
|
||||
}
|
||||
|
||||
// Change is one entry of a diff between two value lists.
|
||||
type Change struct {
|
||||
Removed bool // the value was removed, otherwise added
|
||||
Value string
|
||||
}
|
||||
|
||||
// Diff lists the values removed from and added to a repeatable option, in
|
||||
// file order. Values present in both lists are left out.
|
||||
func Diff(old, new []string) []Change {
|
||||
var out []Change
|
||||
for _, op := range diff(old, new) {
|
||||
switch op.kind {
|
||||
case opDel:
|
||||
out = append(out, Change{true, old[op.i]})
|
||||
case opIns:
|
||||
out = append(out, Change{false, new[op.j]})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Unset removes every entry of key.
|
||||
func (f *File) Unset(key string) {
|
||||
kept := f.Lines[:0:0]
|
||||
for _, l := range f.Lines {
|
||||
if l.Key != key {
|
||||
kept = append(kept, l)
|
||||
}
|
||||
}
|
||||
f.Lines = kept
|
||||
}
|
||||
|
||||
// Bytes renders the file.
|
||||
func (f *File) Bytes() []byte {
|
||||
var b bytes.Buffer
|
||||
for _, l := range f.Lines {
|
||||
b.WriteString(l.Raw)
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
return b.Bytes()
|
||||
}
|
||||
|
||||
// Equal reports whether two files render identically.
|
||||
func (f *File) Equal(o *File) bool {
|
||||
return bytes.Equal(f.Bytes(), o.Bytes())
|
||||
}
|
||||
|
||||
// ChangedOnDisk reports whether the file was modified by someone else since
|
||||
// it was loaded or last saved.
|
||||
func (f *File) ChangedOnDisk() bool {
|
||||
fi, err := os.Stat(f.Path)
|
||||
if err != nil {
|
||||
return f.Exists
|
||||
}
|
||||
return !f.Exists || !fi.ModTime().Equal(f.ModTime)
|
||||
}
|
||||
|
||||
// target returns the real file behind Path, so that saving a symlinked
|
||||
// config (e.g. from a dotfiles repository) keeps the symlink intact.
|
||||
func (f *File) target() string {
|
||||
if t, err := filepath.EvalSymlinks(f.Path); err == nil {
|
||||
return t
|
||||
}
|
||||
return f.Path
|
||||
}
|
||||
|
||||
// WriteTemp writes the file's content to a temporary file next to the
|
||||
// target, so that relative config-file includes resolve the same way.
|
||||
func (f *File) WriteTemp() (string, error) {
|
||||
target := f.target()
|
||||
dir := filepath.Dir(target)
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
tmp, err := os.CreateTemp(dir, "."+filepath.Base(target)+".ghosttyconf-*")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if _, err := tmp.Write(f.Bytes()); err != nil {
|
||||
tmp.Close()
|
||||
os.Remove(tmp.Name())
|
||||
return "", err
|
||||
}
|
||||
if err := tmp.Close(); err != nil {
|
||||
os.Remove(tmp.Name())
|
||||
return "", err
|
||||
}
|
||||
return tmp.Name(), nil
|
||||
}
|
||||
|
||||
// Save atomically replaces the file on disk. When backup is true and the
|
||||
// file exists, the previous version is kept as <path>.bak.
|
||||
func (f *File) Save(backup bool) error {
|
||||
target := f.target()
|
||||
mode := fs.FileMode(0o644)
|
||||
if fi, err := os.Stat(target); err == nil {
|
||||
mode = fi.Mode().Perm()
|
||||
if backup {
|
||||
old, err := os.ReadFile(target)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read for backup: %w", err)
|
||||
}
|
||||
if err := os.WriteFile(target+".bak", old, mode); err != nil {
|
||||
return fmt.Errorf("write backup: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp, err := f.WriteTemp()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Chmod(tmp, mode); err != nil {
|
||||
os.Remove(tmp)
|
||||
return err
|
||||
}
|
||||
if err := os.Rename(tmp, target); err != nil {
|
||||
os.Remove(tmp)
|
||||
return err
|
||||
}
|
||||
f.Exists = true
|
||||
if fi, err := os.Stat(f.Path); err == nil {
|
||||
f.ModTime = fi.ModTime()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const sample = `# My Ghostty config
|
||||
font-family = Hack Nerd Font Mono
|
||||
font-size=15
|
||||
|
||||
keybind = a=new_tab
|
||||
# split navigation
|
||||
keybind = b=goto_split:next
|
||||
|
||||
theme = "Dracula"
|
||||
# trailing comment
|
||||
`
|
||||
|
||||
func parse(t *testing.T, s string) *File {
|
||||
t.Helper()
|
||||
return &File{Lines: Parse([]byte(s))}
|
||||
}
|
||||
|
||||
func TestRoundTripPreservesEverything(t *testing.T) {
|
||||
f := parse(t, sample)
|
||||
if got := string(f.Bytes()); got != sample {
|
||||
t.Fatalf("round trip changed the file:\n%s", got)
|
||||
}
|
||||
if v, _ := f.Get("font-size"); v != "15" {
|
||||
t.Errorf("font-size = %q", v)
|
||||
}
|
||||
if v, _ := f.Get("theme"); v != `"Dracula"` {
|
||||
t.Errorf("theme should keep its quotes, got %q", v)
|
||||
}
|
||||
if got := f.Keys(); strings.Join(got, ",") != "font-family,font-size,keybind,theme" {
|
||||
t.Errorf("keys = %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetUpdatesInPlace(t *testing.T) {
|
||||
f := parse(t, sample)
|
||||
f.Set("font-size", "16")
|
||||
want := strings.Replace(sample, "font-size=15", "font-size = 16", 1)
|
||||
if got := string(f.Bytes()); got != want {
|
||||
t.Fatalf("got:\n%s\nwant:\n%s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetAppendsAfterLastEntry(t *testing.T) {
|
||||
f := parse(t, sample)
|
||||
f.Set("cursor-style", "bar")
|
||||
want := strings.Replace(sample, "theme = \"Dracula\"\n", "theme = \"Dracula\"\ncursor-style = bar\n", 1)
|
||||
if got := string(f.Bytes()); got != want {
|
||||
t.Fatalf("got:\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetRemovesDuplicates(t *testing.T) {
|
||||
f := parse(t, "a = 1\nb = 2\na = 3\n")
|
||||
f.Set("a", "4")
|
||||
if got := string(f.Bytes()); got != "a = 4\nb = 2\n" {
|
||||
t.Fatalf("got:\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetAllKeepsPositions(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
values []string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "append",
|
||||
values: []string{"a=new_tab", "b=goto_split:next", "c=close_surface"},
|
||||
want: "keybind = a=new_tab\n# split navigation\nkeybind = b=goto_split:next\nkeybind = c=close_surface\n",
|
||||
},
|
||||
{
|
||||
name: "edit second",
|
||||
values: []string{"a=new_tab", "b=goto_split:previous"},
|
||||
want: "keybind = a=new_tab\n# split navigation\nkeybind = b=goto_split:previous\n",
|
||||
},
|
||||
{
|
||||
name: "delete first",
|
||||
values: []string{"b=goto_split:next"},
|
||||
want: "# split navigation\nkeybind = b=goto_split:next\n",
|
||||
},
|
||||
{
|
||||
name: "insert at front",
|
||||
values: []string{"z=reset", "a=new_tab", "b=goto_split:next"},
|
||||
want: "keybind = z=reset\nkeybind = a=new_tab\n# split navigation\nkeybind = b=goto_split:next\n",
|
||||
},
|
||||
{
|
||||
name: "swap",
|
||||
values: []string{"b=goto_split:next", "a=new_tab"},
|
||||
// The comment stays attached to the entry it describes.
|
||||
want: "# split navigation\nkeybind = b=goto_split:next\nkeybind = a=new_tab\n",
|
||||
},
|
||||
}
|
||||
const base = "keybind = a=new_tab\n# split navigation\nkeybind = b=goto_split:next\n"
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
f := parse(t, base)
|
||||
f.SetAll("keybind", tt.values)
|
||||
if got := string(f.Bytes()); got != tt.want {
|
||||
t.Fatalf("got:\n%s\nwant:\n%s", got, tt.want)
|
||||
}
|
||||
if got := f.GetAll("keybind"); strings.Join(got, "|") != strings.Join(tt.values, "|") {
|
||||
t.Fatalf("values = %v", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnset(t *testing.T) {
|
||||
f := parse(t, sample)
|
||||
f.Unset("keybind")
|
||||
if f.Has("keybind") {
|
||||
t.Fatal("keybind still present")
|
||||
}
|
||||
if !strings.Contains(string(f.Bytes()), "# split navigation") {
|
||||
t.Fatal("comments must be kept")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatLineQuoting(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"bar": "k = bar",
|
||||
"": `k = ""`,
|
||||
" x": `k = " x"`,
|
||||
`"quoted"`: `k = "quoted"`,
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := FormatLine("k", in); got != want {
|
||||
t.Errorf("FormatLine(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSaveBackupAndSymlink(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
real := filepath.Join(dir, "real.ghostty")
|
||||
link := filepath.Join(dir, "config.ghostty")
|
||||
if err := os.WriteFile(real, []byte("font-size = 12\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink(real, link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f, err := Load(link)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.Set("font-size", "14")
|
||||
if err := f.Save(true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fi, err := os.Lstat(link); err != nil || fi.Mode()&os.ModeSymlink == 0 {
|
||||
t.Fatal("symlink was replaced")
|
||||
}
|
||||
got, _ := os.ReadFile(real)
|
||||
if string(got) != "font-size = 14\n" {
|
||||
t.Fatalf("saved content = %q", got)
|
||||
}
|
||||
bak, _ := os.ReadFile(real + ".bak")
|
||||
if string(bak) != "font-size = 12\n" {
|
||||
t.Fatalf("backup content = %q", bak)
|
||||
}
|
||||
if fi, _ := os.Stat(real); fi.Mode().Perm() != 0o600 {
|
||||
t.Fatalf("permissions changed to %v", fi.Mode().Perm())
|
||||
}
|
||||
if f.ChangedOnDisk() {
|
||||
t.Fatal("file should not be reported as changed after our own save")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadMissingFile(t *testing.T) {
|
||||
f, err := Load(filepath.Join(t.TempDir(), "nope"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if f.Exists || len(f.Lines) != 0 {
|
||||
t.Fatal("expected empty, non-existing file")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffListsOnlyChanges(t *testing.T) {
|
||||
old := []string{"super+d=new_split:right", "super+shift+d=new_split:down", "super+k=unbind"}
|
||||
new := []string{"super+shift+d=new_split:down", "super+k=unbind", "super+d=unbind", `super+\=new_split:right`}
|
||||
got := Diff(old, new)
|
||||
want := []Change{{true, "super+d=new_split:right"}, {false, "super+d=unbind"}, {false, `super+\=new_split:right`}}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("Diff = %v, want %v", got, want)
|
||||
}
|
||||
for i := range want {
|
||||
if got[i] != want[i] {
|
||||
t.Fatalf("Diff = %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user