本文整理汇总了Golang中github.com/fatih/color.Blue函数的典型用法代码示例。如果您正苦于以下问题:Golang Blue函数的具体用法?Golang Blue怎么用?Golang Blue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Blue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
Repo := [6]string{"https://github.com/EgeBalci/ARCANUS/blob/master/SOURCE/ARCANUS.go", "https://github.com/EgeBalci/ARCANUS/raw/master/ARCANUS_x64", "https://github.com/EgeBalci/ARCANUS/raw/master/ARCANUS_x64.exe", "https://github.com/EgeBalci/ARCANUS/raw/master/ARCANUS_x86", "https://github.com/EgeBalci/ARCANUS/raw/master/ARCANUS_x86.exe", "https://github.com/EgeBalci/ARCANUS/raw/master/README.md"}
if runtime.GOOS == "windows" {
exec.Command("cmd", "/C", "msg ARCANUS Update Started...").Run()
exec.Command("cmd", "/C", "del ARCANUS.go").Run()
exec.Command("cmd", "/C", "del ARCANUS_x64.exe").Run()
exec.Command("cmd", "/C", "del ARCANUS_x86.exe").Run()
exec.Command("cmd", "/C", "del ARCANUS_x64").Run()
exec.Command("cmd", "/C", "del ARCANUS_x86").Run()
color.Blue("[*] Updating ARCANUS...\n\n")
for i := 0; i < len(Repo); i++ {
response, _ := http.Get(Repo[i])
defer response.Body.Close()
body, _ := ioutil.ReadAll(response.Body)
Name := strings.Split(Repo[i], "/")
color.Green("# " + string(Name[(len(Name)-1)]) + " [OK]")
file, _ := os.Create(string(Name[(len(Name) - 1)]))
file.WriteString(string(body))
}
/*ARC, _ := exec.Command("cmd", "/C", "echo %PROCESSOR_ARCHITECTURE%").Output()
if strings.Contains(string(ARC), "x86") || strings.Contains(string(ARC), "X86") {
exec.Command("cmd", "/C", "ARCANUS_x86.exe").Start()
}else if strings.Contains(string(ARC), "AMD64") {
exec.Command("cmd", "/C", "ARCANUS_x64.exe").Start()
}*/
exec.Command("cmd", "/C", "msg * ARCANUS Updated Succesfuly !").Run()
} else if runtime.GOOS == "linux" {
exec.Command("sh", "-c", "zenity --info --text=\"ARCANUS Update Started... \"").Run()
exec.Command("sh", "-c", "rm ARCANUS.go").Run()
exec.Command("sh", "-c", "rm ARCANUS_x64.exe").Run()
exec.Command("sh", "-c", "rm ARCANUS_x86.exe").Run()
exec.Command("sh", "-c", "rm ARCANUS_x64").Run()
exec.Command("sh", "-c", "rm ARCANUS_x86").Run()
color.Blue("[*] Updating ARCANUS...\n\n")
for i := 0; i < len(Repo); i++ {
response, _ := http.Get(Repo[i])
defer response.Body.Close()
body, _ := ioutil.ReadAll(response.Body)
Name := strings.Split(Repo[i], "/")
color.Green("# " + string(Name[(len(Name)-1)]) + " [OK]")
file, _ := os.Create(string(Name[(len(Name) - 1)]))
file.WriteString(string(body))
}
exec.Command("sh", "-c", "zenity --info --text=\"ARCANUS Updated Succesfuly !\"").Run()
/*ARC, _ := exec.Command("sh", "-c", "uname -a").Output()
if strings.Contains(string(ARC), "x86") || strings.Contains(string(ARC), "X86") {
exec.Command("sh", "-c", "./ARCANUS_x86").Start()
}else if strings.Contains(string(ARC), "amd64") {
exec.Command("sh", "-c", "./ARCANUS_x64").Start()
}*/
}
}
示例2: userInputFrequency
func userInputFrequency(reader *bufio.Reader) time.Duration {
color.Blue("Backup Frequency, use a short string like: 30m or 2h43m10s")
color.Blue("Valid time units are: h, m, s")
fmt.Println("")
fmt.Print("Backup Every: ")
text, _ := reader.ReadString('\n')
text = strings.TrimSpace(text)
d, err := time.ParseDuration(text)
if err != nil {
color.Red("Error parsing frequency, try again")
return userInputFrequency(reader)
}
return d
}
示例3: main
func main() {
if all_ssh.ArgsInfo.IP != "" {
color.Yellow("开始登录:%s\n", all_ssh.ArgsInfo.IP)
var v all_ssh.ConnetctionInfo
for _, v = range all_ssh.ServerList {
if v.IP == all_ssh.ArgsInfo.IP {
break
}
}
v.IP = all_ssh.ArgsInfo.IP
client := all_ssh.Connection(v)
if client == nil {
return
}
err := all_ssh.TtyClient(client)
if err != nil {
println(err.Error())
}
if len(all_ssh.ErrorList) >= 1 {
color.Red(all_ssh.ErrorList[0])
}
return
}
if all_ssh.ArgsInfo.File != "" {
copyfile()
return
}
if all_ssh.ArgsInfo.Cmd != "" {
runcmd()
return
}
color.Blue("使用%s -h查看帮助.\n", os.Args[0])
}
示例4: copyfile
func copyfile() {
color.Yellow("开始执行文件发送:")
info, err := os.Lstat(all_ssh.ArgsInfo.File)
if err != nil || info.IsDir() {
color.Blue("检查要发送的文件.")
return
}
for _, v := range all_ssh.ServerList {
go func() {
client := all_ssh.Connection(v)
if client != nil {
all_ssh.CopyFile(client, all_ssh.ArgsInfo.File, all_ssh.ArgsInfo.Dir)
}
}()
}
var num int
var Over chan os.Signal = make(chan os.Signal, 1)
go signal.Notify(Over, os.Interrupt, os.Kill)
go result(&num, Over)
<-Over
color.Yellow("一共有%d条错误.\n", len(all_ssh.ErrorList))
for _, v := range all_ssh.ErrorList {
color.Red(v)
}
color.Red("收到结果:%d条\n", num)
}
示例5: main
// TEST="asdf,asdf,asdf" ./main template.tpl
func main() {
if len(os.Args) != 2 {
color.Red("tenv: v.01")
color.Blue("------------------------")
color.Cyan("Prepopulates to stdin given template with information stored in env variables")
color.Cyan("variables should follow go template syntax {{.VAR_NAME}}")
color.Cyan("and must be declared on the environment")
color.Cyan("Usage : tenv filename")
os.Exit(1)
}
var funcMap template.FuncMap
funcMap = template.FuncMap{
"split": strings.Split,
}
file := filepath.Base(os.Args[1])
t, err := template.New(file).Funcs(funcMap).ParseFiles(os.Args[1])
if err != nil {
log.Fatalf("Error: %s", err)
}
context := make(map[string]string)
for _, v := range os.Environ() {
p := strings.Split(v, "=")
context[p[0]] = p[1]
}
err = t.ExecuteTemplate(os.Stdout, file, context)
if err != nil {
log.Fatal(err)
}
}
示例6: main
func main() {
checkArgs()
url := os.Args[1]
directory := os.Args[2]
r, err := git.NewFilesystemRepository(directory)
checkIfError(err)
// Clone the given repository, using depth we create a shallow clone :
// > git clone <url> --depth 1
color.Blue("git clone %s --depth 1 %s", url, directory)
err = r.Clone(&git.CloneOptions{
URL: url,
})
checkIfError(err)
// ... retrieving the branch being pointed by HEAD
ref, err := r.Head()
checkIfError(err)
// ... retrieving the commit object
commit, err := r.Commit(ref.Hash())
checkIfError(err)
fmt.Println(commit)
os.Exit(0)
// ... we get all the files from the commit
files, err := commit.Files()
checkIfError(err)
// ... now we iterate the files to save to disk
err = files.ForEach(func(f *git.File) error {
abs := filepath.Join(directory, f.Name)
dir := filepath.Dir(abs)
os.MkdirAll(dir, 0777)
file, err := os.Create(abs)
if err != nil {
return err
}
defer file.Close()
r, err := f.Reader()
if err != nil {
return err
}
defer r.Close()
if err := file.Chmod(f.Mode); err != nil {
return err
}
_, err = io.Copy(file, r)
return err
})
checkIfError(err)
}
示例7: clone
func clone(r *git.Repository, url string) {
// Clone the given repository, all the objects, references and
// configuration sush as remotes, are save into the Aerospike database.
// > git clone <url>
color.Blue("git clone %s", url)
err := r.Clone(&git.CloneOptions{URL: url})
checkIfError(err)
}
示例8: userInputType
func userInputType(reader *bufio.Reader) string {
color.Blue("Which type of backup destination would you like to add?")
color.Blue(" 1. Amazon (S3 or Glacier)")
color.Blue(" 2. Google Cloud")
fmt.Println("")
fmt.Print("Choose an option [1-2]: ")
text, _ := reader.ReadString('\n')
destType := strings.TrimSpace(text)
switch destType {
case "1":
destType = "amazon"
case "2":
destType = "google"
default:
os.Exit(1)
}
return destType
}
示例9: verifyPlatform
// verifyPlatform should in the future verify that your {arch, platform,
// os, etc.} match for the given file
func (lib Lib) verifyPlatform() bool {
out, err := execShellCmd("strings " + lib.Fname + " | grep " + runtime.GOOS)
if err != nil {
log.Println(err)
}
color.Blue(string(out))
return true
}
示例10: show
func show(dict Dict) {
for _, ps := range dict.Ps {
color.Green(ps)
}
for index, pos := range dict.Pos {
color.Red(strings.TrimSpace(pos))
color.Yellow(strings.TrimSpace(dict.Acceptation[index]))
}
for _, sent := range dict.SentList {
color.Blue("ex. %s", strings.TrimSpace(sent.Orig))
color.Cyan(" %s", strings.TrimSpace(sent.Trans))
}
}
示例11: main
func main() {
var configFileContents []byte
var conf Config
var changedFiles []string
var tests []string
var err error
if configFileContents, err = ioutil.ReadFile("testdiff.toml"); err != nil {
color.Red("Loading configuration failed!")
return
}
if _, err := toml.Decode(string(configFileContents), &conf); err != nil {
color.Red("Loading configuration failed!")
return
}
color.Blue("Scanning for changed files...")
if changedFiles, err = findChangedFiles(conf); err != nil {
color.Red("Diffing failed!")
return
}
color.Blue("Determining what tests to run...")
if tests, err = determineTestsToExecute(conf, changedFiles); err != nil {
color.Red("Test locating failed!")
return
}
color.Blue("Executing tests.")
if err = executeTests(conf, tests); err != nil {
color.Red("Running tests failed!")
return
}
color.Green("All done!")
}
示例12: ghostInTheCircuits
// This SIFT app will randomly alter any detected lights
func ghostInTheCircuits(server *sift.Server, minMS, maxMS int) {
for {
// Wait for a random amount of time
<-time.After(randTime(minMS, maxMS))
// Get all lights connected to the system
lightsQuery := `
SELECT c.name, c.device_id FROM component c
JOIN device d ON c.device_id=d.id
WHERE is_online=1 AND type=?`
lights := []db.Component{}
db, err := server.DB()
if err != nil {
color.Red("could not open DB: %v", err)
}
// run the query
if err = db.Select(&lights, lightsQuery, types.LightEmitter{}.Type()); err != nil {
color.Red("could not run query to get light ids: %v", err)
}
if len(lights) == 0 {
color.Red("no lights found for the circuit ghosts to play with...")
} else {
// For each light found...
for _, light := range lights {
// ...assemble a component ID...
lightID := types.ComponentID{
Name: light.Name,
DeviceID: types.DeviceID(light.DeviceID),
}
// ...generate a random brightness value (0-100)...
randBrightness := uint8(rand.Intn(100))
// ...then create and submit an intent
newLightIntent := types.SetLightEmitterIntent{
BrightnessInPercent: randBrightness,
}
if err := server.EnactIntent(lightID, newLightIntent); err != nil {
color.Red("could not enact intent: %v", err)
} else {
color.Blue("set light %v to %v", lightID, randBrightness)
}
}
}
}
}
示例13: repeatUpdatesToConsole
// main starts a sift server and listens for updates, printing any to console.
func repeatUpdatesToConsole(server *sift.Server) {
myToken := server.Login()
updateChan := server.Listen(myToken) // without specifying filters, this will listen to everything
fmt.Println("listening to SIFT server and printing updates to console...")
for {
update := <-updateChan //TODO: uncaught panic if updateChan is closed
switch typed := update.(type) {
case notif.ComponentNotification:
color.Blue("component %+v %v: %+v\n", typed.ID, typed.Action, typed.Component)
//case notif.DriverNotification:
// fmt.Printf("driver %v: %v", typed.NotificationType, typed.Component)
default:
color.Red("unhandled update type from updateChan: %T (%v)\n", update, update)
}
}
}
示例14: runDelete
func runDelete(args []string) {
config := stash.NewConfig()
reader := bufio.NewReader(os.Stdin)
color.Red("WARNING! Deleted entries cannot be recovered")
color.Blue("Please choose one of the following entries: ")
for _, entry := range config.Entries {
color.Magenta(" %s", entry.Name)
}
fmt.Println()
fmt.Print("Entry to delete (case-sensitive): ")
text, _ := reader.ReadString('\n')
text = strings.TrimSpace(text)
err := config.DeleteEntry(text)
if err != nil {
color.Red("Fatal error deleting an entry: %s", err)
os.Exit(1)
}
}
示例15: strike_create
func strike_create(c *cli.Context) error {
url := c.GlobalString("url")
if url == "" {
return cli.NewExitError("A URL must be provided with the SCALE_URL environment variable or the --url argument", 1)
}
data_file := c.String("data")
var strike_data scalecli.StrikeData
err := Parse_json_or_yaml(data_file, &strike_data)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
strike_process_id, err := scalecli.CreateStrikeProcess(url, strike_data)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
color.Blue(fmt.Sprintf("Strike process %d created.", strike_process_id))
return nil
}