Skip to content

Commit 11d92a0

Browse files
committed
Decamel separates pkg name with colon
Go documentation
1 parent b29d8e7 commit 11d92a0

File tree

8 files changed

+16
-10
lines changed

8 files changed

+16
-10
lines changed

assert/assert_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func ExampleThat() {
1818
}
1919
err := sample()
2020
fmt.Printf("%v", err)
21-
// Output: testing run example: assertion test
21+
// Output: testing: run example: assertion test
2222
}
2323

2424
func ExampleNotNil() {

err2_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func TestPanicking_Handle(t *testing.T) {
182182
},
183183
annErr,
184184
},
185-
{"general error thru panic",
185+
{"general error thru panic: handle nil: no automatic",
186186
args{
187187
func() (err error) {
188188
// If we want keep same error value second argument
@@ -393,7 +393,7 @@ func ExampleHandle_errThrow() {
393393
}
394394
err := transport()
395395
fmt.Printf("%v", err)
396-
// Output: testing run example: our error
396+
// Output: testing: run example: our error
397397
}
398398

399399
func ExampleHandle_errReturn() {

filecopy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ func Example() {
4040
// in real word example 'run example' is 'copy file' it comes automatically
4141
// from function name that calls `err2.Handle` in deferred.
4242

43-
// Output: testing run example: open /notfound/path/file.go: no such file or directory
43+
// Output: testing: run example: open /notfound/path/file.go: no such file or directory
4444
}

internal/handler/handler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ func Process(info *Info) {
226226
}
227227
}
228228

229+
// PreProcess is currently used for err2 API like err2.Handle and .Catch.
230+
// - replaces the Process
229231
func PreProcess(errPtr *error, info *Info, a ...any) error {
230232
// Bug in Go?
231233
// start to use local error ptr only for optimization reasons.

internal/str/str.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func Decamel(s string) string {
4545
if toSpace {
4646
if prevSkipped {
4747
continue
48+
} else if v == '.' {
49+
b.WriteRune(':')
4850
}
4951
v = ' '
5052
prevSkipped = true

internal/str/str_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ func TestDecamel(t *testing.T) {
4040
{"acronym", args{"ARMCamelString"}, "armcamel string"},
4141
{"acronym at end", args{"archIsARM"}, "arch is arm"},
4242
{"simple method", args{"(*DIDAgent).AssertWallet"}, "didagent assert wallet"},
43-
{"package name and simple method", args{"ssi.(*DIDAgent).AssertWallet"}, "ssi didagent assert wallet"},
44-
{"simple method and anonym", args{"(*DIDAgent).AssertWallet.Func1"}, "didagent assert wallet func1"},
45-
{"complex method and anonym", args{"(**DIDAgent).AssertWallet.Func1"}, "didagent assert wallet func1"},
46-
{"unnatural method and anonym", args{"(**DIDAgent)...AssertWallet...Func1"}, "didagent assert wallet func1"},
47-
{"from spf13 cobra", args{"bot.glob..func5"}, "bot glob func5"},
43+
{"package name and simple method", args{"ssi.(*DIDAgent).AssertWallet"}, "ssi: didagent assert wallet"},
44+
{"simple method and anonym", args{"(*DIDAgent).AssertWallet.Func1"}, "didagent assert wallet: func1"},
45+
{"complex method and anonym", args{"(**DIDAgent).AssertWallet.Func1"}, "didagent assert wallet: func1"},
46+
{"unnatural method and anonym", args{"(**DIDAgent)...AssertWallet...Func1"}, "didagent assert wallet: func1"},
47+
{"from spf13 cobra", args{"bot.glob..func5"}, "bot: glob: func5"},
4848
}
4949
for _, tt := range tests {
5050
s := tt.args.s

samples/main-db-sample.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/lainio/err2/try"
1010
)
1111

12+
// TODO: test migrations with these samples!
13+
1214
func (db *Database) MoneyTransfer(from, to *Account, amount int) (err error) {
1315
defer err2.Handle(&err)
1416

try/result2_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ func ExampleResult2_Logf() {
2929
num1, num2 := countSomething("WRONG", "2")
3030
fmt.Printf("results: %d, %d", num1, num2)
3131
err2.SetLogTracer(nil)
32-
// Output: testing run example: strconv.Atoi: parsing "WRONG": invalid syntax
32+
// Output: testing: run example: strconv.Atoi: parsing "WRONG": invalid syntax
3333
// results: 20, 10
3434
}

0 commit comments

Comments
 (0)