utils

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright 2017 bee authors

Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

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 BeeFuncMap

func BeeFuncMap() template.FuncMap

BeeFuncMap returns a FuncMap of functions used in different templates.

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 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 IsBeegoProject

func IsBeegoProject(thePath string) bool

IsBeegoProject checks whether the current path is a Beego application or not

func IsExist

func IsExist(path string) bool

IsExist returns whether a file or directory exists.

func IsInGOPATH

func IsInGOPATH(thePath string) bool

IsInGOPATH checks whether the path is inside of any GOPATH 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 Notify

func Notify(text, title string)

func PrintErrorAndExit

func PrintErrorAndExit(message, errorTemplate string)

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