Я использую dep ensure
для установки GIN, но не удалось.
step0. Моя среда
- ОС: macOS Catalina 10.15
- Версия GO: 1.13.3
- Деп версия: devel
- Цель версии GIN: 1.4.0
- подробная информация о депо:
dep version
dep:
version : devel
build date :
git hash :
go version : go1.13.3
go compiler : gc
platform : darwin/amd64
features : ImportDuringSolve=false
- Я нахожусь в Китае, но для завершения работы использую VPN.
step1,dep init
Я открываю новое и чистое рабочее пространство и задаю переменную среды GOPATH с этим путем. После этого я использовал команду dep init
для генерации Gopkg.lock и Gopkg.toml. Тогда моей структуре работы каталога нравится нижняя сторона:
tree ./
./
└── main
├── Gopkg.lock
├── Gopkg.toml
├── main.go
└── vendor
2 directories, 3 files
step2. Добавить пакет зависимостей
Затем я редактирую файл Gopkg.toml, чтобы добавить пакет зависимостей. После редактирования содержимое файла Gopkg.toml:
[prune]
go-tests = true
unused-packages = true
[[constraint]]
name = "github.com/gin-gonic/gin"
version = "=1.4.0"
step3. добавьте import
в main.go
После этой работы я добавил import
код в main.go для зависимости от GIN. Код в main.go:
package main
import "fmt"
import _ "github.com/gin-gonic/gin"
func main() {
fmt.Println("hello")
}
step4. запустить dep ensure -v
После всех работ я запускаю dep ensure -v
, чтобы добавить GIN в vendor /, но не получилось. Полные сообщения об ошибках:
dep ensure -v
# Gopkg.lock is out of sync with Gopkg.toml and project imports:
github.com/gin-gonic/gin: imported or required, but missing from Gopkg.lock's input-imports
Root project is "project1"
1 transitively valid internal packages
1 external packages imported from 1 projects
(0) ✓ select (root)
(1) ? attempt github.com/gin-gonic/gin with 1 pkgs; 22 versions to try
(1) try github.com/gin-gonic/gin@v1.4.0
(1) ✗ failed to fetch source for https://github.com/gin-gonic/gin: unable to get repository: Cloning into '/Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin'...
(1) fatal: Unable to read current working directory: No such file or directory
(1) : command failed: [git clone --recursive -v --progress https://github.com/gin-gonic/gin /Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin]: exit status 128
(1) try github.com/gin-gonic/gin@v1.3.0
(2) ✗ github.com/gin-gonic/gin@v1.3.0 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.2
(2) ✗ github.com/gin-gonic/gin@v1.2 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.4
(2) ✗ github.com/gin-gonic/gin@v1.1.4 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.3
(2) ✗ github.com/gin-gonic/gin@v1.1.3 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.2
(2) ✗ github.com/gin-gonic/gin@v1.1.2 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.1
(2) ✗ github.com/gin-gonic/gin@v1.1.1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1
(2) ✗ github.com/gin-gonic/gin@v1.1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.0
(2) ✗ github.com/gin-gonic/gin@v1.0 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.6
(2) ✗ github.com/gin-gonic/gin@v0.6 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.5
(2) ✗ github.com/gin-gonic/gin@v0.5 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.4
(2) ✗ github.com/gin-gonic/gin@v0.4 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.3
(2) ✗ github.com/gin-gonic/gin@v0.3 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.1
(2) ✗ github.com/gin-gonic/gin@v0.1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.0-rc.2
(2) ✗ github.com/gin-gonic/gin@v1.0-rc.2 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@master
(2) ✗ github.com/gin-gonic/gin@master not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@benchmarks
(2) ✗ github.com/gin-gonic/gin@benchmarks not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@better-bind-errors
(2) ✗ github.com/gin-gonic/gin@better-bind-errors not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@new-catch-all
(2) ✗ github.com/gin-gonic/gin@new-catch-all not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@thinkerou-patch-1
(2) ✗ github.com/gin-gonic/gin@thinkerou-patch-1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.2b
(2) ✗ github.com/gin-gonic/gin@v0.2b not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.0rc1
(2) ✗ github.com/gin-gonic/gin@v1.0rc1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) ← no more versions of github.com/gin-gonic/gin to try; begin backtrack
✗ solving failed
Solver wall times by segment:
b-source-exists: 4.720311329s
b-list-pkgs: 40.258443ms
satisfy: 308.319µs
new-atom: 147.694µs
select-root: 47.319µs
b-list-versions: 40.806µs
other: 13.401µs
TOTAL: 4.761127311s
Solving failure: No versions of github.com/gin-gonic/gin met constraints:
v1.4.0: failed to fetch source for https://github.com/gin-gonic/gin: unable to get repository: Cloning into '/Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin'...
fatal: Unable to read current working directory: No such file or directory
: command failed: [git clone --recursive -v --progress https://github.com/gin-gonic/gin /Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin]: exit status 128
v1.3.0: Could not introduce github.com/gin-gonic/gin@v1.3.0, as it is not allowed by constraint 1.4.0 from project project1.
v1.2: Could not introduce github.com/gin-gonic/gin@v1.2, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.4: Could not introduce github.com/gin-gonic/gin@v1.1.4, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.3: Could not introduce github.com/gin-gonic/gin@v1.1.3, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.2: Could not introduce github.com/gin-gonic/gin@v1.1.2, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.1: Could not introduce github.com/gin-gonic/gin@v1.1.1, as it is not allowed by constraint 1.4.0 from project project1.
v1.1: Could not introduce github.com/gin-gonic/gin@v1.1, as it is not allowed by constraint 1.4.0 from project project1.
v1.0: Could not introduce github.com/gin-gonic/gin@v1.0, as it is not allowed by constraint 1.4.0 from project project1.
v0.6: Could not introduce github.com/gin-gonic/gin@v0.6, as it is not allowed by constraint 1.4.0 from project project1.
v0.5: Could not introduce github.com/gin-gonic/gin@v0.5, as it is not allowed by constraint 1.4.0 from project project1.
v0.4: Could not introduce github.com/gin-gonic/gin@v0.4, as it is not allowed by constraint 1.4.0 from project project1.
v0.3: Could not introduce github.com/gin-gonic/gin@v0.3, as it is not allowed by constraint 1.4.0 from project project1.
v0.1: Could not introduce github.com/gin-gonic/gin@v0.1, as it is not allowed by constraint 1.4.0 from project project1.
v1.0-rc.2: Could not introduce github.com/gin-gonic/gin@v1.0-rc.2, as it is not allowed by constraint 1.4.0 from project project1.
master: Could not introduce github.com/gin-gonic/gin@master, as it is not allowed by constraint 1.4.0 from project project1.
benchmarks: Could not introduce github.com/gin-gonic/gin@benchmarks, as it is not allowed by constraint 1.4.0 from project project1.
better-bind-errors: Could not introduce github.com/gin-gonic/gin@better-bind-errors, as it is not allowed by constraint 1.4.0 from project project1.
new-catch-all: Could not introduce github.com/gin-gonic/gin@new-catch-all, as it is not allowed by constraint 1.4.0 from project project1.
thinkerou-patch-1: Could not introduce github.com/gin-gonic/gin@thinkerou-patch-1, as it is not allowed by constraint 1.4.0 from project project1.
v0.2b: Could not introduce github.com/gin-gonic/gin@v0.2b, as it is not allowed by constraint 1.4.0 from project project1.
v1.0rc1: Could not introduce github.com/gin-gonic/gin@v1.0rc1, as it is not allowed by constraint 1.4.0 from project project1.
Я обращаю внимание на решениеинформация об ошибке. Я полагаю, что ошибка относится к Solving failure: No versions of github.com/gin-gonic/gin met constraints:
, но я не могу найти полезную информацию для ее устранения. Пожалуйста, помогите мне. Большое спасибо!
Я искал в Google и stackOverFlow. Некоторые предлагают разрешить мне использовать http_proxy, но бесполезно.
main.go
package main
import "fmt"
import _ "github.com/gin-gonic/gin"
func main() {
fmt.Println("hello")
}
Gopkg.toml
[prune]
go-tests = true
unused-packages = true
[[constraint]]
name = "github.com/gin-gonic/gin"
version = "=1.4.0"
Gopkg.lock
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
input-imports = []
solver-name = "gps-cdcl"
solver-version = 1
Я ожидал успешной установки GIN. Все сообщения об ошибках:
dep ensure -v
# Gopkg.lock is out of sync with Gopkg.toml and project imports:
github.com/gin-gonic/gin: imported or required, but missing from Gopkg.lock's input-imports
Root project is "project1"
1 transitively valid internal packages
1 external packages imported from 1 projects
(0) ✓ select (root)
(1) ? attempt github.com/gin-gonic/gin with 1 pkgs; 22 versions to try
(1) try github.com/gin-gonic/gin@v1.4.0
(1) ✗ failed to fetch source for https://github.com/gin-gonic/gin: unable to get repository: Cloning into '/Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin'...
(1) fatal: Unable to read current working directory: No such file or directory
(1) : command failed: [git clone --recursive -v --progress https://github.com/gin-gonic/gin /Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin]: exit status 128
(1) try github.com/gin-gonic/gin@v1.3.0
(2) ✗ github.com/gin-gonic/gin@v1.3.0 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.2
(2) ✗ github.com/gin-gonic/gin@v1.2 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.4
(2) ✗ github.com/gin-gonic/gin@v1.1.4 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.3
(2) ✗ github.com/gin-gonic/gin@v1.1.3 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.2
(2) ✗ github.com/gin-gonic/gin@v1.1.2 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1.1
(2) ✗ github.com/gin-gonic/gin@v1.1.1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.1
(2) ✗ github.com/gin-gonic/gin@v1.1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.0
(2) ✗ github.com/gin-gonic/gin@v1.0 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.6
(2) ✗ github.com/gin-gonic/gin@v0.6 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.5
(2) ✗ github.com/gin-gonic/gin@v0.5 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.4
(2) ✗ github.com/gin-gonic/gin@v0.4 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.3
(2) ✗ github.com/gin-gonic/gin@v0.3 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.1
(2) ✗ github.com/gin-gonic/gin@v0.1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.0-rc.2
(2) ✗ github.com/gin-gonic/gin@v1.0-rc.2 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@master
(2) ✗ github.com/gin-gonic/gin@master not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@benchmarks
(2) ✗ github.com/gin-gonic/gin@benchmarks not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@better-bind-errors
(2) ✗ github.com/gin-gonic/gin@better-bind-errors not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@new-catch-all
(2) ✗ github.com/gin-gonic/gin@new-catch-all not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@thinkerou-patch-1
(2) ✗ github.com/gin-gonic/gin@thinkerou-patch-1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v0.2b
(2) ✗ github.com/gin-gonic/gin@v0.2b not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) try github.com/gin-gonic/gin@v1.0rc1
(2) ✗ github.com/gin-gonic/gin@v1.0rc1 not allowed by constraint 1.4.0:
(2) 1.4.0 from (root)
(1) ← no more versions of github.com/gin-gonic/gin to try; begin backtrack
✗ solving failed
Solver wall times by segment:
b-source-exists: 4.720311329s
b-list-pkgs: 40.258443ms
satisfy: 308.319µs
new-atom: 147.694µs
select-root: 47.319µs
b-list-versions: 40.806µs
other: 13.401µs
TOTAL: 4.761127311s
Solving failure: No versions of github.com/gin-gonic/gin met constraints:
v1.4.0: failed to fetch source for https://github.com/gin-gonic/gin: unable to get repository: Cloning into '/Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin'...
fatal: Unable to read current working directory: No such file or directory
: command failed: [git clone --recursive -v --progress https://github.com/gin-gonic/gin /Users/yanglei/Desktop/goDepStudy/pkg/dep/sources/https---github.com-gin--gonic-gin]: exit status 128
v1.3.0: Could not introduce github.com/gin-gonic/gin@v1.3.0, as it is not allowed by constraint 1.4.0 from project project1.
v1.2: Could not introduce github.com/gin-gonic/gin@v1.2, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.4: Could not introduce github.com/gin-gonic/gin@v1.1.4, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.3: Could not introduce github.com/gin-gonic/gin@v1.1.3, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.2: Could not introduce github.com/gin-gonic/gin@v1.1.2, as it is not allowed by constraint 1.4.0 from project project1.
v1.1.1: Could not introduce github.com/gin-gonic/gin@v1.1.1, as it is not allowed by constraint 1.4.0 from project project1.
v1.1: Could not introduce github.com/gin-gonic/gin@v1.1, as it is not allowed by constraint 1.4.0 from project project1.
v1.0: Could not introduce github.com/gin-gonic/gin@v1.0, as it is not allowed by constraint 1.4.0 from project project1.
v0.6: Could not introduce github.com/gin-gonic/gin@v0.6, as it is not allowed by constraint 1.4.0 from project project1.
v0.5: Could not introduce github.com/gin-gonic/gin@v0.5, as it is not allowed by constraint 1.4.0 from project project1.
v0.4: Could not introduce github.com/gin-gonic/gin@v0.4, as it is not allowed by constraint 1.4.0 from project project1.
v0.3: Could not introduce github.com/gin-gonic/gin@v0.3, as it is not allowed by constraint 1.4.0 from project project1.
v0.1: Could not introduce github.com/gin-gonic/gin@v0.1, as it is not allowed by constraint 1.4.0 from project project1.
v1.0-rc.2: Could not introduce github.com/gin-gonic/gin@v1.0-rc.2, as it is not allowed by constraint 1.4.0 from project project1.
master: Could not introduce github.com/gin-gonic/gin@master, as it is not allowed by constraint 1.4.0 from project project1.
benchmarks: Could not introduce github.com/gin-gonic/gin@benchmarks, as it is not allowed by constraint 1.4.0 from project project1.
better-bind-errors: Could not introduce github.com/gin-gonic/gin@better-bind-errors, as it is not allowed by constraint 1.4.0 from project project1.
new-catch-all: Could not introduce github.com/gin-gonic/gin@new-catch-all, as it is not allowed by constraint 1.4.0 from project project1.
thinkerou-patch-1: Could not introduce github.com/gin-gonic/gin@thinkerou-patch-1, as it is not allowed by constraint 1.4.0 from project project1.
v0.2b: Could not introduce github.com/gin-gonic/gin@v0.2b, as it is not allowed by constraint 1.4.0 from project project1.
v1.0rc1: Could not introduce github.com/gin-gonic/gin@v1.0rc1, as it is not allowed by constraint 1.4.0 from project project1.
Спасибо за вашу помощь!