-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from qor/qor_view_path_in_gomod
check pkg/mod, then check gopath/src
- Loading branch information
Showing
4 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,8 +87,9 @@ adm.GetRouter().PrintRoutes() | |
QOR was developed before go mod was introduced. So it still support go path while finding its template files. The priority is | ||
|
||
1. check vendor, if not found | ||
2. check $GOPATH/src/github.com/qor/admin/views, if still not found | ||
3. load view path from $GOPATH/pkg/mod/github.com/qor/[email protected]/views. the version would be detected automatically by you go.sum file | ||
2. check $GOPATH/pkg/mod/github.com/qor/[email protected]/views. the version would be detected automatically by your go.mod file, if still not found | ||
3. load view path from $GOPATH/src/github.com/qor/admin/views | ||
|
||
|
||
So if you want to use the template under the pkg/mod, make sure $GOPATH/src/github.com/qor/admin is absent. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package admin | |
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
|
@@ -23,10 +22,10 @@ func TestGetDepVersionFromMod(t *testing.T) { | |
{view: "github.com/qor/publish2/views", want: "pkg/mod/github.com/qor/[email protected]/views"}, | ||
{view: "github.com/qor/media/media_library/views", want: "pkg/mod/github.com/qor/[email protected]/media_library/views"}, | ||
{view: "github.com/qor/i18n/exchange_actions/views", want: "pkg/mod/github.com/qor/[email protected]/exchange_actions/views"}, | ||
{view: "no/unknown/nonexistent", want: "no/unknown/nonexistent"}, | ||
} | ||
for _, v := range cases { | ||
pth := strings.TrimSuffix(v.view, "/views") | ||
if got := getDepVersionFromMod(pth) + "/views"; v.want != got { | ||
if got := getDepVersionFromMod(v.view); v.want != got { | ||
t.Errorf("GetDepVersionFromMod-viewpath: %v, want: %v, got: %v", v.view, v.want, got) | ||
} else { | ||
fmt.Println(got) | ||
|