helper

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 10 Imported by: 11

README

go-helper

Simple helper functions for GO program.

Usage

import	"github.com/J-Siu/go-helper"

func main() {
	helper.Debug = true
	helper.DebugLog("debug msg")
}

Repository

Contributors

Change Log

  • 0.0.1
    • Initial Commit
  • 0.9.0
    • Function update
  • 0.9.1
    • Fix git command args
  • v0.9.1
    • Add prefix v for version number

License

The MIT License

Copyright (c) 2022 John Siu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool = false

Functions

func BoolStatus

func BoolStatus(b bool) string

bool to "OK"/"Fail"

func BoolString

func BoolString(b bool) string

bool to "true"/"false"

func BoolYesNo

func BoolYesNo(b bool) string

func BoxSealAnonymous

func BoxSealAnonymous(key, msg *string) *string

func CurrentDirBase

func CurrentDirBase() string

func DebugEnv

func DebugEnv() bool

DebugEnv - set debug flag from env

func DebugLog

func DebugLog(msg ...interface{})

DebugLog - msg

func ErrCheck

func ErrCheck(e error)

ErrCheck - check error

func GitRemote

func GitRemote(v bool) *[]string

func GitRemoteExist

func GitRemoteExist(name string) bool

Check if specified remote exist in repository

func GitRemoteRemoveAll

func GitRemoteRemoveAll()

Remove all remotes from repository

func JsonIndentSp

func JsonIndentSp(baP *[]byte, endl bool) *string

func Report

func Report(data any, title string, skipEmpty bool)

func ReportDebug

func ReportDebug(data any, title string, skipEmpty bool)

func ReportSp

func ReportSp(data any, title string, skipEmpty bool) *string

func ReportStatus

func ReportStatus(data bool, title string)

func StrArrayPtrContain

func StrArrayPtrContain(aP *[]string, sP *string) bool

func StrArrayPtrPrintln

func StrArrayPtrPrintln(saP *[]string)

func StrArrayPtrRemoveEmpty

func StrArrayPtrRemoveEmpty(saP *[]string) *[]string

Remove empty lines in a strng array

func StrPToArrayP

func StrPToArrayP(sP *string) *[]string

Types

type MyCmd

type MyCmd struct {
	ArgsP  *[]string    `json:"ArgsP"`  // Command args
	Name   string       `json:"Name"`   // Command name
	CmdLn  string       `json:"CmdLn"`  // Out: Command Line
	Err    error        `json:"Err"`    // Out: run error
	Stdout bytes.Buffer `json:"Stdout"` // Out: Stdout
	Stderr bytes.Buffer `json:"Stderr"` // Out: Stderr
}

func GitInit

func GitInit() *MyCmd

Git init

func GitPush

func GitPush(optionsP []string) *MyCmd

func GitRemoteAdd

func GitRemoteAdd(name string, git string) *MyCmd

func GitRemoteRemove

func GitRemoteRemove(name string) *MyCmd

Remove specified remotes from repository

func MyCmdRun

func MyCmdRun(name string, argsP *[]string) *MyCmd

func MyCmdRunWg

func MyCmdRunWg(name string, argsP *[]string, title *string, wgP *sync.WaitGroup, output bool) *MyCmd

func (*MyCmd) Run

func (self *MyCmd) Run() error

type ReportT

type ReportT struct {
	Data       any    `json:"Data"`
	Title      string `json:"Title"`
	SkipEmpty  bool   `json:"SkipEmpty"`  // Return empty string if Data is empty
	ModeStatus bool   `json:"ModeStatus"` // bool to "OK/Failed"
}

func ReportNew

func ReportNew(data any, title string, skipEmpty bool) *ReportT

func (*ReportT) String

func (self *ReportT) String() string

func (*ReportT) StringDebug

func (self *ReportT) StringDebug() string

func (*ReportT) StringP

func (self *ReportT) StringP() *string

func (*ReportT) StringPDebug

func (self *ReportT) StringPDebug() *string

Report with debug check

Jump to

Keyboard shortcuts

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