go-james: github.com/pieterclaerhout/go-james/internal/common Index | Files

package common

import "github.com/pieterclaerhout/go-james/internal/common"

Index

Package Files

badge.go command_runner.go compressor.go encoding.go filenames.go filesystem.go golang.go logging.go package_name.go project.go template.go timer.go

Constants

const BuildDirName = "build"

BuildDirName defines the name of the build folder

const CmdDirName = "cmd"

CmdDirName defines the name of the cmd folder

const GitIgnoreFileName = ".gitignore"

GitIgnoreFileName defines the name for .gitignore

const GitRepoFileName = ".git"

GitRepoFileName defines the name for .git

const GoModFileName = "go.mod"

GoModFileName defines the name for go.mod

const LicenseFileName = "LICENSE"

LicenseFileName defines the name for LICENSE

const ReadmeFileName = "README.md"

ReadmeFileName defines the name for README.md

const ScriptDirName = "scripts"

ScriptDirName defines the name of the scripts folder

const ScriptPostBuild = "post_build"

ScriptPostBuild defines the name of the post_build script

const ScriptPreBuild = "pre_build"

ScriptPreBuild defines the name of the pre_build script

const VersionInfoFileName = "versioninfo.go"

VersionInfoFileName defines the name for versioninfo.go

const VersionInfoPackage = "versioninfo"

VersionInfoPackage defines the name for the version info package

Variables

var (
    // ErrEmptyCommand is returned when the command is empty
    ErrEmptyCommand = errors.New("No command specified")
)

func PackageNameToShort Uses

func PackageNameToShort(packageName string) string

PackageNameToShort converts a package name to it's short version

type Badge Uses

type Badge struct {
    Title string // The title of the badge
    Link  string // The link to link to
    Image string // The src of the image for the badge
}

Badge is used to link with a badge to a specific URL

func (Badge) MarkdownString Uses

func (badge Badge) MarkdownString() string

MarkdownString returns the badge as a Markdown string

type CommandRunner Uses

type CommandRunner struct {
    FileSystem
    Encoding
}

CommandRunner is what can be injected into a subcommand when you need to run system commands

func (CommandRunner) RunInteractive Uses

func (commandRunner CommandRunner) RunInteractive(cmdLine []string, workdir string, env map[string]string) error

RunInteractive and interactive command

func (CommandRunner) RunProjectHook Uses

func (commandRunner CommandRunner) RunProjectHook(project Project, hookName string, args interface{}) error

RunProjectHook runs the given hook in the context of the project passing the args to ti

func (CommandRunner) RunReturnOutput Uses

func (commandRunner CommandRunner) RunReturnOutput(cmdLine []string, workdir string, env map[string]string) (string, error)

RunReturnOutput runs the command and returns the result as a string

func (CommandRunner) RunScriptIfExistsReturnOutput Uses

func (commandRunner CommandRunner) RunScriptIfExistsReturnOutput(scriptPath string, args interface{}, workdir string, env map[string]string) (string, error)

RunScriptIfExistsReturnOutput runs the given script if it exists using "go run" and outputs the result to stdout/stderr

func (CommandRunner) RunScriptIfExistsToStdout Uses

func (commandRunner CommandRunner) RunScriptIfExistsToStdout(scriptPath string, args interface{}, workdir string, env map[string]string) error

RunScriptIfExistsToStdout runs the given script if it exists using "go run" and outputs the result to stdout/stderr

func (CommandRunner) RunScriptReturnOutput Uses

func (commandRunner CommandRunner) RunScriptReturnOutput(scriptPath string, args interface{}, workdir string, env map[string]string) (string, error)

RunScriptReturnOutput runs the given script using "go run" and outputs the result to stdout/stderr

func (CommandRunner) RunScriptToStdout Uses

func (commandRunner CommandRunner) RunScriptToStdout(scriptPath string, args interface{}, workdir string, env map[string]string) error

RunScriptToStdout runs the given script using "go run" and outputs the result to stdout/stderr

func (CommandRunner) RunToStdout Uses

func (commandRunner CommandRunner) RunToStdout(cmdLine []string, workdir string, env map[string]string) error

RunToStdout runs the command and outputs the result to stdout/stderr

type Compressor Uses

type Compressor struct{}

Compressor is what can be injected into a subcommand when you need zip / tgz functions

func (Compressor) CreateTgz Uses

func (c Compressor) CreateTgz(tgzPath string) compressors.Compressor

CreateTgz creates a tgz file from a path

func (Compressor) CreateZip Uses

func (c Compressor) CreateZip(zipPath string) compressors.Compressor

CreateZip creates a zip file from a path

type Encoding Uses

type Encoding struct{}

Encoding is what can be injected into a subcommand when you need encoding-related items

func (Encoding) ToFormattedString Uses

func (e Encoding) ToFormattedString(data interface{}) string

ToFormattedString returns a JSON formatted string encoding data

func (Encoding) ToJSON Uses

func (e Encoding) ToJSON(data interface{}) []byte

ToJSON returns a JSON byte slice encoding data

func (Encoding) ToJSONString Uses

func (e Encoding) ToJSONString(data interface{}) string

ToJSONString returns a JSON string encoding data

type FileSystem Uses

type FileSystem struct {
    Logging
}

FileSystem is what can be injected into a subcommand when you need file system access

func (FileSystem) DirExists Uses

func (fileSystem FileSystem) DirExists(path string) bool

DirExists is a helper function to check if a directory exists or not

func (FileSystem) FileExists Uses

func (fileSystem FileSystem) FileExists(path string) bool

FileExists is a helper function to check if a file exists or not

func (FileSystem) PathExists Uses

func (fileSystem FileSystem) PathExists(path string) bool

PathExists is a helper function to check if a path exists or not

func (FileSystem) WriteJSONFile Uses

func (fileSystem FileSystem) WriteJSONFile(path string, data interface{}) error

WriteJSONFile marshals the data into a JSON file

func (FileSystem) WriteJSONFileIfNotExists Uses

func (fileSystem FileSystem) WriteJSONFileIfNotExists(path string, data interface{}) error

WriteJSONFileIfNotExists writes JSON into a file if it doesn't exist yet

func (FileSystem) WriteTextFile Uses

func (fileSystem FileSystem) WriteTextFile(path string, data string) error

WriteTextFile creates a text with with data as its contents

func (FileSystem) WriteTextFileIfNotExists Uses

func (fileSystem FileSystem) WriteTextFileIfNotExists(path string, data string) error

WriteTextFileIfNotExists writes a text file if it doesn't exist yet

type Golang Uses

type Golang struct{}

Golang is what can be injected into a subcommand when you need Go specific items

func (Golang) GoBin Uses

func (g Golang) GoBin(subpath ...string) string

GoBin returns a relative path inside $GOPATH/bin

func (Golang) GoPath Uses

func (g Golang) GoPath(subpath ...string) string

GoPath returns a relative path inside $GOPATH

type Logging Uses

type Logging struct{}

Logging is what can be injected into a subcommand when you need logging

func (Logging) LogError Uses

func (logging Logging) LogError(args ...interface{})

LogError logs an error

func (Logging) LogErrorInDebugMode Uses

func (logging Logging) LogErrorInDebugMode(args ...interface{})

LogErrorInDebugMode logs an error when running in debug mode

func (Logging) LogInfo Uses

func (logging Logging) LogInfo(args ...interface{})

LogInfo logs an info message

func (Logging) LogPathCreation Uses

func (logging Logging) LogPathCreation(prefix string, path string)

LogPathCreation logs the creation of a file path

type Project Uses

type Project struct {
    FileSystem

    Path string
    // contains filtered or unexported fields
}

Project defines a Go project based on Go modules

func NewProject Uses

func NewProject(path string, packageName string) Project

NewProject returns a new Project instance

func (Project) Badges Uses

func (project Project) Badges() []Badge

Badges returns the list of badges which should be shown for the project

func (Project) Package Uses

func (project Project) Package() (string, error)

Package gets the main package of the project from the go.mod file

func (Project) RelPath Uses

func (project Project) RelPath(subpath ...string) string

RelPath returns a relative path inside the project

func (Project) ShortPackageName Uses

func (project Project) ShortPackageName() string

ShortPackageName returns the package name for the main package

type Template Uses

type Template struct {
    FileSystem
}

Template is what can be injected into a subcommand when you need text templates

func (Template) RenderTextTemplate Uses

func (t Template) RenderTextTemplate(templateData string, params interface{}) (string, error)

RenderTextTemplate renders a text template

func (Template) WriteTextTemplateIfNotExists Uses

func (t Template) WriteTextTemplateIfNotExists(path string, templateData string, params interface{}) error

WriteTextTemplateIfNotExists renders a text template and writes it to a file if it doesn't exist yet

type Timer Uses

type Timer struct {
    // contains filtered or unexported fields
}

Timer is what can be injected into a subcommand when you need a timer

func (*Timer) PrintElapsed Uses

func (t *Timer) PrintElapsed(prefix string)

PrintElapsed prints the elapsed time to stdout

func (*Timer) StartTimer Uses

func (t *Timer) StartTimer()

StartTimer starts the timer

Package common imports 18 packages (graph) and is imported by 12 packages. Updated 2019-12-14. Refresh now. Tools for package owners.