util

package
v0.0.0-...-5a1af90 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Unlicense Imports: 13 Imported by: 2

Documentation

Overview

Package util provides helper methods for development. This package is for offline processing and not used in frontend code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BypassReader

func BypassReader(label string, input io.Reader) (io.Reader, error)

BypassReader is a workaround to process UTF-16 XML. See

https://groups.google.com/forum/#!topic/golang-nuts/tXcECEKC2rs
https://stackoverflow.com/a/50812725

for more information.

func CheckDownload

func CheckDownload(url, filePath string, overwrite bool) (err error)

CheckDownload is the same as Download, except the third argument specifies whether to overwrite local file if it already exists.

func CreateDirIfNotExist

func CreateDirIfNotExist(filepath string)

CreateDirIfNotExist creates the directory containing the file if the directory does not exist, given the path of the file. Similar to the shell command “mkdir -p“. This method does not return error. If the directory cannot be made, this method panics.

func DecodeUtf16XML

func DecodeUtf16XML(r io.Reader, v interface{}) (err error)

DecodeUtf16XML decodes UTF-16 encoded XML. The first argument could be an UTF-16 encoded XML file opened by os.Open method. The seconde argument is the struct used to decode the XML.

func Download

func Download(url, filePath string) (err error)

Download downloads the url to local path specified by the second argument. If the local file already exists, it will be overwritten.

func IsRunOnGitHubActions

func IsRunOnGitHubActions() bool

IsRunOnGitHubActions checks if running on GitHub Actions environment.

func IsRunOnGitLabCI

func IsRunOnGitLabCI() bool

IsRunOnGitLabCI checks if running on GitLab CI/CD environment.

func IsRunOnTravisCI

func IsRunOnTravisCI() bool

IsRunOnTravisCI checks if running on TRAVIS CI environment.

func LoadJsonConfig

func LoadJsonConfig(fp string) (conf map[string]string, err error)

LoadJsonConfig loads map[string]string data from the json file. Make sure the given JSON file is of the struct map[string]string.

func LocalPrintln

func LocalPrintln(a ...interface{})

LocalPrintln will not print on Travis CI or GitLab CI/CD environment.

func PrettyPrint

func PrettyPrint(v interface{}) (err error)

PrettyPrint pretty-prints Go variable (struct, map, array, slice, etc.).

func ReadlinesFromFile

func ReadlinesFromFile(filePath string) (lines []string, err error)

ReadlinesFromFile reads lines from the file.

func S2T

func S2T(s string) string

S2T converts Simplified Chinese to Traditional Chinese.

func SaveJsonFile

func SaveJsonFile(v interface{}, path string)

SaveJsonFile saves the data to JSON file.

func T2S

func T2S(s string) string

T2S converts traditional Chinese to Simplified Chinese.

func TwPoToCN

func TwPoToCN(twPOPath, cnPOPath string)

TwPoToCN creates the zh_CN PO file from the given zh_TW PO file.

func Zg2uni

func Zg2uni(str string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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