Skip to content

Commit 54ebf46

Browse files
authored
doc: update readme to use os-specific path separator (#534)
* update readme to use os-specific path separator * shorten getShortLineNo example to one liner
1 parent bda298d commit 54ebf46

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

README.md

+1-9
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,7 @@ Equivalent of `Lshortfile`:
412412

413413
```go
414414
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
415-
short := file
416-
for i := len(file) - 1; i > 0; i-- {
417-
if file[i] == '/' {
418-
short = file[i+1:]
419-
break
420-
}
421-
}
422-
file = short
423-
return file + ":" + strconv.Itoa(line)
415+
return filepath.Base(file) + ":" + strconv.Itoa(line)
424416
}
425417
log.Logger = log.With().Caller().Logger()
426418
log.Info().Msg("hello world")

0 commit comments

Comments
 (0)