Documentation
¶
Index ¶
- Constants
- Variables
- func Build(log *log.Logger, buildOpts BuildOpts) error
- func BuildFuncList(opts RunOpts, dir string) ([]function, error)
- func BuildGlobal(opts RunOpts) error
- func BuildLocal(opts RunOpts) error
- func GenerateMainFile(opts RunOpts) error
- func GetPlainType(field *ast.Field) string
- func Init(folder, goModPath string) error
- func Run(opts RunOpts, args []string) error
- func ShowFuncList(opts RunOpts) (int, error)
- type BuildOpts
- type GoCmd
- type GoFlag
- type RunOpts
Constants ¶
const GOGOIMPORTPATH = "github.com/2bit-software/gogo/pkg/gogo"
const MAIN_FILENAME = "main.gogo.go"
const (
REQUIRED_VERSION = "v1.24.0"
)
Variables ¶
Functions ¶
func Build ¶
Build reads all the gogo files in the directory, applies their configuration options, and builds the resulting binary. The buildDir is the directory in which we are building the source FROM. The output of the binary can be specified in the buildOpts.OutputFilepath
func BuildFuncList ¶
BuildFuncList builds a list of functions that can be run. It combines both local and global functions. If there are name collisions, the local one takes precedence, and the global one can be used with a prefix. e.g. `gogo g:funcName` would run the global function `funcName`
func BuildGlobal ¶
func BuildLocal ¶
BuildLocal searches for the local gogo files, and builds the binary
func GetPlainType ¶
GetPlainType takes an *ast.Field and returns a plain-English type description
func Init ¶
Init a new GoGo project. It's assumed the folder is the full path to what should be made and where the files should be places. The gogoModPath is the go.mod module path to use.
func Run ¶
Run this is a simplified version of the Run function in cmd/gogo/main.go For now it only searches for the local gogo files, and does not try to determine if the function exists in the global cache.
func ShowFuncList ¶
ShowFuncList lists all the available functions in the local and global namespaces
Types ¶
type BuildOpts ¶
type BuildOpts struct {
KeepArtifacts bool `json:"GOGO_KEEP_ARTIFACTS"` // When true, keeps the artifacts after the build. This includes the go src and the built binary
DisableCache bool `json:"GOGO_DISABLE_CACHE"` // When true, forces a rebuild of the binary
Optimize bool `json:"GOGO_OPTIMIZE"` // should the functions be compiled with optimization flags during this run
BinaryFilepath string `json:"GOGO_OUTPUT"` // the output location of the binary. If this is provided, then we don't calculate the filename or the location
// The below properties are calculated by the build process
SourceDir string // the location of the directory where we are currently building the source
OutputDir string // the output location of the binaries
OriginalWorkingDir string // the original working directory
}
type GoCmd ¶
type GoCmd struct {
Name string // Name of the command
Short string // Short Description of the command. Comes from the comment, unless overridden.
Long string // Long Description of the command. This comes from the comment, if it exists.
Example string // An example of using this command
GoFlags []GoFlag
ErrorReturn bool // If true, the command returns an error
UseGoGoContext bool // If true, the command uses the gogo context
}
type GoFlag ¶
type GoFlag struct {
Type string // string, int, bool, float64 This type is inferred from reading the code.
Name string // name of the flag
Short byte // short name of the flag
Default any // default value of the flag.
HasDefault bool // if true, use the default value
Help string // help text for the flag
AllowedValues []any // if provided, only these values are allowed, and are auto-completed in the shell
RestrictedValues []any // if provided, prohibits this flag from being set to these values. Panics if detected.
}
type RunOpts ¶
type RunOpts struct {
BuildOpts
Verbose bool `json:"GOGO_VERBOSE"` // output verbose information when RUNNING gogo AND the sub-command
GlobalSourceDir string `json:"GOGO_GLOBAL_SOURCE_DIR"` // the global location for gogo functions
GlobalBinDir string `json:"GOGO_GLOBAL_BIN_DIR"` // the output location for global binaries
BuildLocalCache bool `json:"GOGO_BUILD_LOCAL"` // When true, builds the local cache and exits
BuildGlobalCache bool `json:"GOGO_BUILD_GLOBAL"` // When true, builds the global cache and exits
ScreenWidth int // the width of the screen, if we know
// contains filtered or unexported fields
}