diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-05 21:27:17 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-05 21:27:17 +0800 |
commit | e0635b47c2f30719e1ea026812af85c988632c0e (patch) | |
tree | f112904c018dc294cf6f902423745f1f1932449c /internal/misc/misc.go | |
parent | Export symbols from database.go (diff) | |
download | forge-e0635b47c2f30719e1ea026812af85c988632c0e.tar.gz forge-e0635b47c2f30719e1ea026812af85c988632c0e.tar.zst forge-e0635b47c2f30719e1ea026812af85c988632c0e.zip |
Move things to internal/v0.1.23
Diffstat (limited to 'internal/misc/misc.go')
-rw-r--r-- | internal/misc/misc.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/misc/misc.go b/internal/misc/misc.go new file mode 100644 index 0000000..ee0fd7a --- /dev/null +++ b/internal/misc/misc.go @@ -0,0 +1,21 @@ +package misc + +import "strings" + +func FirstOrPanic[T any](v T, err error) T { + if err != nil { + panic(err) + } + return v +} + +// sliceContainsNewlines returns true if and only if the given slice contains +// one or more strings that contains newlines. +func SliceContainsNewlines(s []string) bool { + for _, v := range s { + if strings.Contains(v, "\n") { + return true + } + } + return false +} |