caicloud / nirvana

Golang Restful API Framework for Productivity
https://caicloud.github.io/nirvana/
Apache License 2.0
520 stars 105 forks source link

feat(cmd::api): work with go module #371

Closed knight42 closed 4 years ago

knight42 commented 4 years ago

What this PR does / why we need it:

Make nirvana api work with go module.

Proof:

$ pwd
/Users/knight/github-caicloud/foo2
[20-10-26 14:31] [kind-kind] byted-mbp@ ~cchub/foo2
$ l
total 48K
drwxr-xr-x 2 knight staff   64 Oct 26 13:27 apis/
drwxr-xr-x 2 knight staff   64 Oct 26 13:27 bin/
drwxr-xr-x 3 knight staff   96 Oct 26 13:27 cmd/
drwxr-xr-x 3 knight staff   96 Oct 26 13:27 build/
drwxr-xr-x 3 knight staff   96 Oct 26 13:27 docs/
drwxr-xr-x 6 knight staff  192 Oct 26 13:27 hack/
drwxr-xr-x 8 knight staff  256 Oct 26 13:27 pkg/
drwxr-xr-x 3 knight staff   96 Oct 26 13:27 test/
-rw-r--r-- 1 knight staff  446 Oct 26 13:27 go.mod
-rw-r--r-- 1 knight staff  460 Oct 26 13:27 nirvana.yaml
-rw-r--r-- 1 knight staff  451 Oct 26 13:27 .golangci.yml
-rw-r--r-- 1 knight staff 5.7K Oct 26 13:27 Makefile
-rw-r--r-- 1 knight staff  544 Oct 26 13:27 README.md
-rw-r--r-- 1 knight staff  23K Oct 26 13:27 go.sum
drwxr-xr-x 7 knight staff  224 Oct 26 13:27 vendor/
[20-10-26 14:31] [kind-kind] byted-mbp@ ~cchub/foo2
$ nirvana api
INFO  1026-14:31:49.258+08 api.go:79 | No packages are specified, defaults to pkg/apis
INFO  1026-14:31:50.823+08 api.go:87 | Project root directory is /Users/knight/github-caicloud/foo2
INFO  1026-14:31:50.824+08 api.go:141 | Listening on 127.0.0.1:8080. Please open your browser to view api docs

Which issue(s) this PR is related to (optional, link to 3rd issue(s)):

Fixes #270

Reference to #

Special notes for your reviewer:

/cc @kdada @iawia002

Release note:

cmd: `nirvana api` is compatible with go module now.
caicloud-bot commented 4 years ago

Thanks for your pull request. Before we can look at your pull request, you'll need to finish a Contributor License Agreement (CLA).

:memo: Please follow instructions at https://github.com/caicloud/engineering/blob/master/guidelines/cla.md to complete the CLA.

Instructions for interacting with me using PR comments are available [here](https://github.com/caicloud/engineering/blob/master/guidelines/caicloud_bot.md). If you have questions or suggestions related to my behavior, please file an issue against the [caicloud/tools](https://github.com/caicloud/tools/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://github.com/caicloud/engineering/blob/master/guidelines/caicloud_bot.md#bot-commands).
iawia002 commented 4 years ago

I got an error in my local validation (with go 1.13.x), seems a go version issue, what is the go version you are using?

error loading packages: go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false --]: exit status 1: build .: cannot find module for path .
knight42 commented 4 years ago

@iawia002 I am using go 1.15.3.

$ go version
go version go1.15.3 darwin/amd64

May i know the command that cause this error?

iawia002 commented 4 years ago

May i know the command that cause this error?

packages.Load returns this error, I tried on go 1.14.x and the issue just disappeared, seems that something wrong with go modules in 1.13.x

iawia002 commented 4 years ago

/lgtm

caicloud-bot commented 4 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iawia002

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/caicloud/nirvana/blob/master/OWNERS)~~ [iawia002] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment