func (o *Options) GetCompileWorkhorse() ([]*Workhorse, error) {
    platforms := allPlatforms
    if o.OS != "all" {
        platforms = platforms.FilterByOS(o.OS)
    }
    if o.Arch != "all" {
        platforms = platforms.FilterByArch(o.Arch)
    }
    var horses []*Workhorse
    if len(platforms) == 0 {
        return horses, ErrNoMatchedPlatform
    }
    for _, platform := range platforms {
        horses = append(horses, &Workhorse{
            Package:    o.Package,
            StandardGO: o.StandardGO,
            Output:     o.Output,
            Platform:   platform,
        })
    }
    return horses, nil
}
GetCompileWorkhorse is used to get all compilation tasks
package cross
import (
    "errors"
    "runtime"
    "strings"
)
var (
    ErrTooManyArguments  = errors.New("too many arguments")
    ErrMissingGoFile     = errors.New("missing target .go file")
    ErrUnexpectedParams  = errors.New("unexpected list of parameters")
    ErrNoMatchedPlatform = errors.New("no matched platform")
)
type Options struct {
    StandardGO []string
    Output  string
    Package string
    Platform
    ShowErr bool
    raw []string
}
func NewOptions(args []string) (*Options, error) {
    options := &Options{
        Platform: Platform{
            OS:   runtime.GOOS,
            Arch: runtime.GOARCH,
        },
        raw: args,
    }
    var pos uint8
    for i := 0; i < len(args); i++ {
        arg := args[i]
        if pos == 0 {
            if arg == "-e" {
                options.ShowErr = true
                continue
            }
            if arg == "-o" {
                i++
                if i < len(args) {
                    options.Output = args[i]
                    continue
                }
                return nil, ErrUnexpectedParams
            }
            if strings.HasSuffix(arg, ".go") {
                pos++
                options.Package = arg
                continue
            }
            options.StandardGO = append(options.StandardGO, arg)
        } else {
            switch pos++; pos {
            case 2:
                options.OS = arg
            case 3:
                options.Arch = arg
            default:
                return nil, ErrTooManyArguments
            }
        }
    }
    if options.Package == "" {
        return nil, ErrMissingGoFile
    }
    return options, nil
}