Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestGopMod: default module #44

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modfile/ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func (e *InvalidExtError) Error() string {

func (e *InvalidExtError) Unwrap() error { return e.Err }

// SplitFname splits fname into (hasGoxExt, className, classExt).
func SplitFname(fname string) (hasGoxExt bool, className, classExt string) {
// SplitFname splits fname into (className, classExt).
func SplitFname(fname string) (className, classExt string) {
classExt = path.Ext(fname)
className = fname[:len(fname)-len(classExt)]
if hasGoxExt = (classExt == ".gox"); hasGoxExt {
if hasGoxExt := (classExt == ".gox"); hasGoxExt {
if n := strings.LastIndexByte(className, '_'); n > 0 {
className, classExt = fname[:n], fname[n:]
}
Expand All @@ -70,6 +70,6 @@ func SplitFname(fname string) (hasGoxExt bool, className, classExt string) {

// ClassExt returns classExt of specified fname.
func ClassExt(fname string) string {
_, _, ext := SplitFname(fname)
_, ext := SplitFname(fname)
return ext
}
17 changes: 15 additions & 2 deletions modfile/regtest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ import (
)

func TestGopMod(t *testing.T) {
if path := gopmod.Default.Path(); path != "" {
t.Fatal("TestGopMod:", path)
mod := gopmod.Default
if mod.HasModfile() {
t.Fatal("gopmod.Default HasModfile?")
}
if path := mod.Modfile(); path != "" {
t.Fatal("gopmod.Default.Modfile?", path)
}
if path := mod.Path(); path != "" {
t.Fatal("gopmod.Default.Path?", path)
}
if path := mod.Root(); path != "" {
t.Fatal("gopmod.Default.Root?", path)
}
if pt := mod.PkgType("foo"); pt != gopmod.PkgtStandard {
t.Fatal("PkgType foo:", pt)
}
}