doufuxi7093 2019-07-25 22:38
浏览 10
已采纳

走,路很崎.。 感谢帮助

Okay well I think Im finally stuck on trying things without some more ideas or help. Im attempting to use
https://github.com/billgraziano/go-windows-svc/blob/master/cmd/gosvc/main.go.
I cloned it over and made adjusted to where the read me states. This is suppose to spin up a service. The service is running what we will cal the DCA which is something that spins up a server.So I haven't even started debugging other issues on that end. The issue is when trying to do a build I get

PS C:\Usersutger\go\src\go-windows-svc\cmd\gosvc> go build main.go

main.go:10:2: cannot find package "bitbucket.org/somepalce/go-dca-base/cmd/dca-agent/main.go" in any of:
        c:\go\src\bitbucket.org\someplace\go-dca-base\cmd\dca-agent\main.go (from $GOROOT)
        C:\Usersutger\go\src\bitbucket.org\somepalce\go-dca-base\cmd\dca-agent\main.go (from $GOPATH)

this is the main from his program but the first import is adjusted relative to where my go path is. package main

import (
    "bitbucket.org/someplace/go-dca-base/cmd/dca-agent/main.go"
    "github.com/pkg/errors"
)

File structure of windows service project

C:\USERS\RUTGER\GO\SRC\GO-WINDOWS-SVC
├───app
└───cmd
    └───gosvc
          -- (has the main)

File structure for DCA

C:\USERS\RUTGER\GO\SRC\BITBUCKET.ORG\SOMEPLACE\GO-DCA-BASE\CMD\DCA-AGENT
├───cmd
       -- (has main for DCA)
├───compile
└───logs

PS C:\Usersutger\go\src\go-windows-svc\cmd\gosvc> go build main.go main.go:10:2: cannot find package "bitbucket.org/somepalce/go-dca-base/cmd/dca-agent/main.go" in any of: c:\go\src\bitbucket.org\somepalce\go-dca-base\cmd\dca-agent\main.go (from $GOROOT) C:\Usersutger\go\src\bitbucket.org\somepalce\go-dca-base\cmd\dca-agent\main.go (from $GOPATH) PS C:\Usersutger\go\src\go-windows-svc\cmd\gosvc>

Output of go env PS C:\Usersutger\go\src\go-windows-svc\cmd\gosvc> go env

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Usersutger\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Usersutger\go
set GOPROXY=
set GORACE=
set GOROOT=c:\go
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Usersutger\AppData\Local\Temp\go-build634488178=/tmp/go-build -gno-record-gcc-switches

Ive read other questions form stack and their req's like:

Cant find package from $GOROOT and $GOPATH

https://forum.golangbridge.org/t/go-build-cant-find-package/11880/10

Cant find package from $GOROOT and $GOPATH

So ya any help is appreciated. I wouldnt think adding in a vendor would have any issues since all the paths seem fine.

  • 写回答

1条回答 默认 最新

  • dougou2937 2019-07-26 14:01
    关注

    Your import of bitbucket.org/printtrackerpro/go-dca-base/cmd/dca-agent/main.go is invalid, for two reasons:

    • In Go you import packages, not files
    • You cannot import the main package at all, because main is the program's entry point and cyclic dependencies are not permitted
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探