util

package
v0.9.0-rc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineOutputPath added in v0.5.0

func CombineOutputPath(outputPath, ns string) string

CombineOutputPath read the output and path variables and render them into the final path

func DownloadFile added in v0.8.0

func DownloadFile(remotePath, localPath string) error

DownloadFile Download file to local

func Exists

func Exists(path string) bool

Exists reports whether a file exists.

func FormatCode

func FormatCode(code []byte) ([]byte, error)

FormatCode formats go source codes.

func GetGOPATH

func GetGOPATH() string

GetGOPATH retrieves the GOPATH from environment variables or the `go env` command.

func JoinPath added in v0.5.2

func JoinPath(elem ...string) string

JoinPath joins dirs as golang import format, such as xx/xx/xx

func LowerFirst

func LowerFirst(s string) string

LowerFirst converts the first letter to upper case for the given string.

func NotPtr

func NotPtr(s string) string

NotPtr converts an pointer type into non-pointer type.

func ReadInput added in v0.8.0

func ReadInput() ([]byte, error)

ReadInput defaults to read from stdin. If `KITEX_TOOL_STDIN_LOAD_FILE` is a valid path, it reads from the specified file; If `KITEX_TOOL_STDIN_DUMP_FILE` is a valid path, it dumps what it read to the file; This feature makes it easier to debug kitex tool.

func ReplaceString added in v0.5.0

func ReplaceString(s, old, new string, n int) string

ReplaceString be used in string substitution.

func RunGitCommand added in v0.4.4

func RunGitCommand(gitLink string) (string, string, error)

func SearchGoMod

func SearchGoMod(cwd string) (moduleName, path string, found bool)

SearchGoMod searches go.mod from the given directory (which must be an absolute path) to the root directory. When the go.mod is found, its module name and path will be returned.

func SnakeString added in v0.5.0

func SnakeString(s string) string

SnakeString converts the string 's' to a snake string

func UpperFirst

func UpperFirst(s string) string

UpperFirst converts the first letter to upper case for the given string.

Types

type StringSlice

type StringSlice []string

StringSlice implements the flag.Value interface on string slices to allow a flag to be set multiple times.

func (*StringSlice) Set

func (ss *StringSlice) Set(value string) error

Set implements the flag.Value interface.

func (*StringSlice) String

func (ss *StringSlice) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL