utils

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: LGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const Radiant_VERSION = "v1.0.14"

Variables

This section is empty.

Functions

func AskForConfirmation

func AskForConfirmation() bool

askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Typically, you should use fmt to print out a question before calling askForConfirmation. E.g. fmt.Println("WARNING: Are you sure? (yes/no)")

func CamelCase

func CamelCase(in string) string

camelCase converts a _ delimited string to camel case e.g. very_important_person => VeryImportantPerson

func CamelString

func CamelString(s string) string

func CheckEnv

func CheckEnv(appname string) (apppath, packpath string, err error)

func CloseFile

func CloseFile(f *os.File)

CloseFile attempts to close the passed file or panics with the actual error

func EndLine

func EndLine() string

EndLine returns the a newline escape character

func FILE

func FILE() string

__FILE__ returns the file name in which the function was invoked

func FormatSourceCode

func FormatSourceCode(filename string)

formatSourceCode formats source files

func GetFileModTime

func GetFileModTime(path string) int64

GetFileModTime returns unix timestamp of `os.File.ModTime` for the given path.

func GetGOPATHs

func GetGOPATHs() []string

GetGOPATHs returns all paths in GOPATH variable.

func GetGoVersionSkipMinor

func GetGoVersionSkipMinor() string

func GetradicalWorkPath

func GetradicalWorkPath() string

func Go

func Go(f func() error) chan error

Go is a basic promise implementation: it wraps calls a function in a goroutine and returns a channel which will later return the function's return value.

func GoCommand

func GoCommand(command string, args ...string) error

GoCommand executes the passed command using Go tool

func IsExist

func IsExist(path string) bool

IsExist returns whether a file or directory exists.

func IsGOMODULE

func IsGOMODULE() bool

func IsInGOPATH

func IsInGOPATH(thePath string) bool

IsInGOPATH checks whether the path is inside of any GOPATH or not

func IsradiantProject

func IsradiantProject(thePath string) bool

IsradiantProject checks whether the current path is a radiant application or not

func LINE

func LINE() int

__LINE__ returns the line number at which the function was invoked

func MacOSVersionSupport

func MacOSVersionSupport() bool

func MustCheck

func MustCheck(err error)

MustCheck panics when the error is not nil

func NoticeUpdateradical

func NoticeUpdateradical()

func Notify

func Notify(text, title string)

func PrintErrorAndExit

func PrintErrorAndExit(message, errorTemplate string)

func RadicalFuncMap

func RadicalFuncMap() template.FuncMap

RadicalFuncMap returns a FuncMap of functions used in different templates.

func SearchGOPATHs

func SearchGOPATHs(app string) (bool, string, string)

SearchGOPATHs searchs the user GOPATH(s) for the specified application name. It returns a boolean, the application's GOPATH and its full path.

func SnakeString

func SnakeString(s string) string

snake string, XxYy to xx_yy

func SplitQuotedFields

func SplitQuotedFields(in string) []string

SplitQuotedFields is like strings.Fields but ignores spaces inside areas surrounded by single quotes. To specify a single quote use backslash to escape it: '\”

func Tmpl

func Tmpl(text string, data interface{})

func TmplToString

func TmplToString(tmpl string, data interface{}) string

TmplToString parses a text template and return the result as a string.

func WriteToFile

func WriteToFile(filename, content string)

WriteToFile creates a file and writes content to it

Types

type DocValue

type DocValue string

func (*DocValue) Set

func (d *DocValue) Set(value string) error

func (*DocValue) String

func (d *DocValue) String() string

type ListOpts

type ListOpts []string

func (*ListOpts) Set

func (opts *ListOpts) Set(value string) error

func (*ListOpts) String

func (opts *ListOpts) String() string

type StrFlags

type StrFlags []string

The string flag list, implemented flag.Value interface

func (*StrFlags) Set

func (s *StrFlags) Set(value string) error

func (*StrFlags) String

func (s *StrFlags) String() string

Jump to

Keyboard shortcuts

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