enhance doc
This commit is contained in:
parent
6d0160ad2a
commit
51dad73b05
@ -110,7 +110,7 @@ func (b *Build) Build() error {
|
|||||||
// the binary name is always same as the directory name of current directory
|
// the binary name is always same as the directory name of current directory
|
||||||
func (b *Build) determineOutputDir(outputDir string) (string, error) {
|
func (b *Build) determineOutputDir(outputDir string) (string, error) {
|
||||||
if b.TmpDir == "" {
|
if b.TmpDir == "" {
|
||||||
return "", fmt.Errorf("can only be called after Build.MvProjectsToTmp(): %w", ErrWrongCallSequence)
|
return "", fmt.Errorf("can only be called after Build.MvProjectsToTmp(): %w", ErrEmptyTempWorkingDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix #43
|
// fix #43
|
||||||
|
@ -70,7 +70,7 @@ func TestCheckParameters(t *testing.T) {
|
|||||||
func TestDetermineOutputDir(t *testing.T) {
|
func TestDetermineOutputDir(t *testing.T) {
|
||||||
b := &Build{}
|
b := &Build{}
|
||||||
_, err := b.determineOutputDir("")
|
_, err := b.determineOutputDir("")
|
||||||
assert.Equal(t, errors.Is(err, ErrWrongCallSequence), true, "called before Build.MvProjectsToTmp() should fail")
|
assert.Equal(t, errors.Is(err, ErrEmptyTempWorkingDir), true, "called before Build.MvProjectsToTmp() should fail")
|
||||||
|
|
||||||
b.TmpDir = "fake"
|
b.TmpDir = "fake"
|
||||||
_, err = b.determineOutputDir("xx")
|
_, err = b.determineOutputDir("xx")
|
||||||
|
@ -5,12 +5,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrShouldNotReached = errors.New("should never be reached")
|
// ErrShouldNotReached represents the logic should not be reached in normal flow
|
||||||
ErrGocShouldExecInProject = errors.New("goc not executed in project directory")
|
ErrShouldNotReached = errors.New("should never be reached")
|
||||||
|
// ErrGocShouldExecInProject represents goc currently not support for the project
|
||||||
|
ErrGocShouldExecInProject = errors.New("goc not support for such project directory")
|
||||||
|
// ErrWrongPackageTypeForInstall represents goc install command only support limited arguments
|
||||||
ErrWrongPackageTypeForInstall = errors.New("packages only support \".\" and \"./...\"")
|
ErrWrongPackageTypeForInstall = errors.New("packages only support \".\" and \"./...\"")
|
||||||
ErrWrongPackageTypeForBuild = errors.New("packages only support \".\"")
|
// ErrWrongPackageTypeForBuild represents goc build command only support limited arguments
|
||||||
ErrTooManyArgs = errors.New("too many args")
|
ErrWrongPackageTypeForBuild = errors.New("packages only support \".\"")
|
||||||
ErrInvalidWorkingDir = errors.New("the working directory is invalid")
|
// ErrTooManyArgs represents goc CLI only support limited arguments
|
||||||
ErrWrongCallSequence = errors.New("function should be called in a specified sequence")
|
ErrTooManyArgs = errors.New("too many args")
|
||||||
ErrNoplaceToInstall = errors.New("dont know where to install")
|
// ErrInvalidWorkingDir represents the working directory is invalid
|
||||||
|
ErrInvalidWorkingDir = errors.New("the working directory is invalid")
|
||||||
|
// ErrEmptyTempWorkingDir represent the error that temporary working directory is empty
|
||||||
|
ErrEmptyTempWorkingDir = errors.New("temporary working directory is empty")
|
||||||
|
// ErrNoPlaceToInstall represents the err that no place to install the generated binary
|
||||||
|
ErrNoPlaceToInstall = errors.New("don't know where to install")
|
||||||
)
|
)
|
||||||
|
@ -172,7 +172,7 @@ func (b *Build) findWhereToInstall() (string, error) {
|
|||||||
|
|
||||||
if false == b.IsMod {
|
if false == b.IsMod {
|
||||||
if b.Root == "" {
|
if b.Root == "" {
|
||||||
return "", ErrNoplaceToInstall
|
return "", ErrNoPlaceToInstall
|
||||||
}
|
}
|
||||||
return filepath.Join(b.Root, "bin"), nil
|
return filepath.Join(b.Root, "bin"), nil
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func TestFindWhereToInstall(t *testing.T) {
|
|||||||
Root: "",
|
Root: "",
|
||||||
}
|
}
|
||||||
_, err := b.findWhereToInstall()
|
_, err := b.findWhereToInstall()
|
||||||
assert.EqualError(t, err, ErrNoplaceToInstall.Error())
|
assert.EqualError(t, err, ErrNoPlaceToInstall.Error())
|
||||||
|
|
||||||
// if $GOBIN not found
|
// if $GOBIN not found
|
||||||
// and if $GOPATH not found
|
// and if $GOPATH not found
|
||||||
|
Loading…
Reference in New Issue
Block a user