/goscript

Simple wrapper around `go run` to use go as a scripting language

Primary LanguageGoMIT LicenseMIT

goscript

Simple wrapper around go run to use go as a scripting language

CLI Usage

$ goscript "fmt.Println("packages will automatically be imported from your $GOPATH")

goscript.go

GoScipt Type

type GoScript struct {
    *exec.Cmd
}

NewFromFile takes in a filePath of golang source and converts it into a GoScript type with an embedded exec.Cmd

func NewFromFile(sourcePath string, args ...string) (*GoScript, error)

NewFromString takes in a string of golang source and converts into a GoScript type with an embedded exec.Cmd

func NewFromString(source string, args ...string) (*GoScript, error)

func (GoScript) Clean

Clean deletes the generated goscript tempfile

func (gs GoScript) Clean() error

func (GoScript) FilePath

FilePath returns the current GoScript's file path

func (gs GoScript) FilePath() string