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 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab