From 5f0b90109aa9eafad5445685f441cb79c9a33fd4 Mon Sep 17 00:00:00 2001 From: Joe Higton Date: Sat, 18 Oct 2025 12:46:59 +0100 Subject: [PATCH] codeberg-ification! --- Readme.org | 4 ++-- filemode.go | 3 +-- filemode_test.go | 3 +-- go.mod | 2 +- json2nd.go | 3 +-- processor.go | 10 +++------- processor_test.go | 7 ++----- 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Readme.org b/Readme.org index 503bad9..fd5c23a 100644 --- a/Readme.org +++ b/Readme.org @@ -39,12 +39,12 @@ For more see [[./doc/other_usage.org][other usage scenarios]], and [[./doc/json_ Assuming your ~$GOBIN~ directory is somewhere in your ~$PATH~ it's as simple as: #+begin_src sh - go install github.com/draxil/json2nd@latest + go install codeberg.org/draxil/json2nd@latest #+end_src ** Github releases -There are builds of release points on github. Grab the relevent build from [[https://github.com/draxil/json2nd/releases][the github releases]] page, right now these just contain a binary and docs. +There are builds of release points on github (but soon codeberg). Grab the relevent build from [[https://github.com/draxil/json2nd/releases][the github releases]] page, right now these just contain a binary and docs. * Plans / what about XYZ? diff --git a/filemode.go b/filemode.go index 570417c..fcc3c7e 100644 --- a/filemode.go +++ b/filemode.go @@ -5,11 +5,10 @@ import ( "io" "os" - "github.com/draxil/json2nd/internal/options" + "codeberg.org/draxil/json2nd/internal/options" ) func filemode(files []string, out io.Writer, opts options.Set) error { - for _, name := range files { f, err := os.Open(name) if err != nil { diff --git a/filemode_test.go b/filemode_test.go index 2abfec5..24baf49 100644 --- a/filemode_test.go +++ b/filemode_test.go @@ -5,12 +5,11 @@ import ( "errors" "testing" - "github.com/draxil/json2nd/internal/options" + "codeberg.org/draxil/json2nd/internal/options" "github.com/stretchr/testify/assert" ) func TestFileMode(t *testing.T) { - cases := []struct { name string files []string diff --git a/go.mod b/go.mod index 5e70094..7228b69 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/draxil/json2nd +module codeberg.org/draxil/json2nd go 1.16 diff --git a/json2nd.go b/json2nd.go index 0917203..5c2d143 100644 --- a/json2nd.go +++ b/json2nd.go @@ -6,13 +6,12 @@ import ( "os" "runtime/debug" - "github.com/draxil/json2nd/internal/options" + "codeberg.org/draxil/json2nd/internal/options" ) var version = "" func main() { - oh, err := options.New(os.Args[1:]) if err != nil { if err == flag.ErrHelp { diff --git a/processor.go b/processor.go index 0984b5e..01559bf 100644 --- a/processor.go +++ b/processor.go @@ -6,8 +6,8 @@ import ( "io" "strings" - "github.com/draxil/json2nd/internal/json" - "github.com/draxil/json2nd/internal/options" + "codeberg.org/draxil/json2nd/internal/json" + "codeberg.org/draxil/json2nd/internal/options" ) type processor struct { @@ -25,7 +25,6 @@ type processor struct { // TODO: path to value? func (p processor) run() error { - if p.in == nil { return errNilInput() } @@ -56,7 +55,6 @@ func (p processor) handlePath(scan *json.JSON) error { } func (p processor) handlePathNodes(nodes []string, scan *json.JSON) error { - // shouldn't be possible? But never say never. if len(nodes) == 0 { return fmt.Errorf("novel error 1: please report") @@ -101,7 +99,6 @@ func (p processor) prepOut() (w io.Writer, finishOut func() error) { } func (p processor) handleArray(js *json.JSON) error { - // shift the cursor from the start of the array: js.MoveOff() @@ -119,7 +116,6 @@ func (p processor) handleArray(js *json.JSON) error { } n, err := js.WriteCurrentTo(out, true) - if err != nil { return arrayJSONErr(err) } @@ -202,7 +198,6 @@ func (p processor) handleNonArray(j *json.JSON, clue byte, topLevel bool) error } func guessJSONType(clue byte) string { - switch clue { case '{': return "object" @@ -247,6 +242,7 @@ func errBadPath(chunk string) error { func errBlankPath() error { return fmt.Errorf("bad blank path node, did you have a double dot?") } + func errPathLeadToBadValue(start byte, path string) error { t := guessJSONType(start) diff --git a/processor_test.go b/processor_test.go index ecfd16b..a2c0eb6 100644 --- a/processor_test.go +++ b/processor_test.go @@ -7,13 +7,12 @@ import ( "strings" "testing" - "github.com/draxil/json2nd/internal/json" - "github.com/draxil/json2nd/internal/options" + "codeberg.org/draxil/json2nd/internal/json" + "codeberg.org/draxil/json2nd/internal/options" "github.com/stretchr/testify/assert" ) func TestProcessor(t *testing.T) { - cases := []struct { name string in io.Reader @@ -422,7 +421,6 @@ func TestProcessor(t *testing.T) { } func TestGuessJsonType(t *testing.T) { - cases := []struct { in byte exp string @@ -449,7 +447,6 @@ func TestGuessJsonType(t *testing.T) { } func TestErrPathLeadToBadValueMessage(t *testing.T) { - cases := []struct { name string clue byte