Documentation
¶
Index ¶
- func GetPackageName(directory string) string
- func JoinNonemptyStrings(sep string, s ...string) string
- func ToGoFilePath(pathString string) string
- func ToGolangName(rawString string, exported bool) string
- func WithoutBy[T comparable, Slice ~[]T](collection Slice, exclude Slice, predicate func(a, b T) bool) Slice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPackageName ¶
GetPackageName returns the last part of the directory path as a package name. If the directory is empty, the function returns "main".
func JoinNonemptyStrings ¶
JoinNonemptyStrings joins non-empty strings with a separator.
func ToGoFilePath ¶
ToGoFilePath converts any path-looking string to the valid path to Go source file path and returns it.
If the path is empty, the function returns a constant file name.
While converting, the function shortens the path by eliminating the dot parts, removes invalid characters from every part, converting the rest to snake case. If an item contains invalid characters only, it is replaced by hash string of the original string to make it non-empty. The last part also will have ".go" file extension.
func ToGolangName ¶
ToGolangName converts any string to a valid Golang name. The exported argument determines if the result should be the exported name (start with an uppercase letter) or not.
This function removes the invalid characters from source string, converts it to camel case or pascal case, makes initialisms uppercase, ensuring that the result doesn't conflict with Golang reserved keywords.
func WithoutBy ¶
func WithoutBy[T comparable, Slice ~[]T](collection Slice, exclude Slice, predicate func(a, b T) bool) Slice
WithoutBy returns slice excluding all given values executing the predicate function.
Types ¶
This section is empty.