There is a problem importing non-standard packages such as github.
I would like to ask you a question for your help.
Let me explain a little bit from the background.
Currently, I am writing the main code using the go language (version 1.6.2).
In this case, the main file is called main.go.go.
However, since we have created many functions, the number of lines in main.go has increased and the length of the compile time has become a concern.To organize the spaghetti code, I moved the function part from this main.go to a different package.In this case, this package is called package.go.
I have experience creating packages before, so creating and checking the operation is fine.
However, unlike before,
Non-standard packages such as github have never been ported to this package.go
In the import part of package.go this time, I wrote the matrix package used in main.go as follows.
import "github.com/skelterjohn/go.matrix"
However, I can no longer use the matrix package that was running on main.go.
The error message is as follows:
non-standard import "github.com/skelterjohn/go.matrix" in standard package "package.go"
I checked the $GOPATH, but
.gvm/pkgsets/go1.6.2/global
github.com dir exists under this global directory.
I didn't think so, but just in case, I created the same matrix package in package.go, but I got the same error message.
In this case, it would be very helpful if you could tell me how you were able to solve the problem.
go
After reviewing the file placement that mjy suggested, the problem was resolved.
Here's a solution for recording.
First of all, when the problem occurred, the file was placed as follows:
(before modification)
main.go->/home/hoge/programs/go
package.go->/home/hoge/.gvm/gos/go1.6.2/src/package
I learned how to place this file when I started writing go.
However, with this method, if you change the version of go, you had to change the file placement of package/package.go.I thought it would be troublesome, but I didn't know how to change it, so I left it as it is.
This time, I was able to solve this problem with two changes.
Changed the directory placement including No.1.package.go.Specifically, I moved the package directory into the directory containing mian.go.
(modified) package.go->/home/hoge/programs/go/package
In addition to this,
Changed the import description in No.2.main.go.Specifically, "./" was added.
Before Modification: import "package"
Corrected: import "./package"
These two points solved the problem.
I didn't study how to install the files properly.
Thank you.
© 2024 OneMinuteCode. All rights reserved.