Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 months ago.
Improve this question
I'm having problems to use packages. I a following literally the steps I find online, but I have an error message.
I have this package in GOPATH:
go/src/greet/day.go
package greet
var morning = "Good morning"
var Morning = "hey" + morning
I want to import it in my code:
go/src/app/entry.go
package main
import ("fmt"
"greet")
func main(){
fmt.Println(greet.Morning)
}
When I run entry.go, I receive this message:
entry.go:4:3: package greet is not in GOROOT (/usr/local/go/src/greet)
Does anybody how to fix it?
Thank you.
GOPATH isn't really used anymore. You can use a different directory and run go mod init greet. This will create a new module "greet" in that folder, and from within that module you can import packages using import "{module name}/{package path}". It is a best practice to use the folder name as the package name, so the import path matches the folder names (except for main packages).
Additionally, if your module lives in a git repository, your module name should be the path to the git repository. for example, go mod init github.com/jaenmo/myrepo.
within your module make a folder for your main package. You should be able to import using your module name.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I updated my flutter today and I had a lot of problems with the image package.
Target of URI doesn't exist: 'package:image/image.dart'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist.darturi_does_not_exist
Make sure you have this is pubspec.yaml,
*note remember to have every space in this file aligned
dependencies:
image: ^2.1.14
Save that file, if you're running VS Code, it will run the command pub get for you automatically, if you're running Android Studio, click on Get Dependencies on the top of the screen after saving the file, otherwise you can do it manually via the terminal with the command pub get
then try again
import 'package:image/image.dart';
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
Let's say, I have the following structure.
export $GOPATH = ~/workspace/go
Directory-Tree:
~/workspace
+ go
+ src
+ example
+ exp1
- main.go
- client.go
+ utils
- my_utils.go
In the file main.go i'd like to import 'client.go' and 'utils/my_utils.go'.
How to do that?
import {
"./client.go"
}
will give me
local import "./client.go" in non-local package
The same happens with any other file in subdirectories like my "utils" folder.
I've read a lot about this error message and about the GOPATH. However, coming from NodeJS and PHP and C++ I really still don't understand this concept of how GoLang will handle file imports and need some further clarification here.
I've read also that people where going to import everything from "GitHub.com", but it makes no sense for me to first push my code to GitHub before I can test it in my local project.
By the way, I'm also curious why go get will not fetch all sub-dependencies together with the specific library that will be fetch with go get?
I've read also that people where going to import everything from "GitHub.com", but it makes no sense for me to first push my code to GitHub before I can test it in my local project.
You don't have to push it anywhere before you can test it. You only have to choose what your import path is, and then put your code in GOPATH accordingly (or use go mod init with Go 1.11+, which lets you place your code anywhere in the filesystem you want). But you still have to pick that import path — even if you decide to change it later.
By the way, I'm also curious why go get will not fetch all sub-dependencies together with the specific library that will be fetch with go get?
It does.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am trying to track and understand the download stats for various go packages to evaluate the download patter over time for the go driver published and released by my team.
Something similar to npm-stats
https://npm-stat.com/
I see similar stats available for pip-python and npm.
https://npm-stat.com/
That may happen once the Go Notary service described in "Go Modules in 2019" is in place:
For publicly-available modules, we intend to run a service we call a notary that follows the module index log, downloads new modules, and cryptographically signs statements of the form “module M at version V has file tree hash H.” The notary service will publish all these notarized hashes in a queryable, Certificate Transparency-style tamper-proof log, so that anyone can verify that the notary is behaving correctly.
This log will serve as a public, global go.sum file that go get can use to authenticate modules when adding or updating dependencies.
We are aiming to have the go command check notarized hashes for publicly-available modules not already in go.sum starting in Go 1.13.
If statistics were to be produced, the Go notary would be a reliable source (for public packages)
Go doesn't have a centralized package registry such as npm or pip.
Also, go dependency management is still not "unified", some use dep some glide or go mod. All of these rely on version control software such as git.
If your package is on Github, you could check the Insights > Traffic tab and see unique cloners for example.
Another solution might be to implement a proxy to your git server to track clones.
You Can't do this.
As those are developed as part of Go language. Like npm packages you are not downloading it.
try gocenter.io, it includes download stats for all modules available. Example - logrus was downloaded 544k+ times - https://search.gocenter.io/github.com~2Fsirupsen~2Flogrus/info?version=v1.4.3-0.20191026113918-67a7fdcf741f
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm using Active perl version 5.22 on windows , When I try to execute a program it says serverCommon.pm is missing , you need to install serverCommon module but I couldn't find a module with the same name from internet, I tried the same for strawberry perl also.
please some one help ,me to resolve this issue .
here is my perl code
use ServerCommon;
$buffer = <<_OUT
CN=""
Domain=""
OU=""
Organization=""
ID=""
_OUT
;
%args = ServerCommon::GenHashFromBuffer($buffer);
Search(%args); # this function is implemented by myself for searching
Thanks in advance.
Firstly, you will find that accuracy is important in programming. In your description you call the module "serverCommon", but in your code it is "ServerCommon". The difference in case is important.
Most Perl modules are distributed on CPAN. But it looks like your missing module isn't there. In fact Google can't find anything useful either.
So it seems that your module must be internal to your organisation. Or, perhaps, part of some software package that isn't installed on your computer.
Where did you get the program that uses this module? My best suggestion would be to go back to the person who gave you this code and ask them where you can get this module from.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
While working on my Go project today, I realised I had ran into a small problem. I had a package that had a struct that held a pointer to a struct from another package. However, that package also made use of a struct from the other package. In C and C++, this wouldn't pose an issue, as I'd use a header guard. However, in Go, such a program won't compile due to infinite import recursion.
This made me wonder, are there too many packages in my project? Should I favour bigger packages? I've always been told that each package should be specifically focused on one thing.
Right now, my structure is like this.
game/ <-- imports engine, needs to access the resource manager a lot
video/ <-- rendering goes here
renderer.go
shader.go
scene.go
...
engine/ <-- imports video, file, etc
root.go <-- contains a Root struct, handles initialisation etc
resource.go
...
file/
dds.go
config.go
resource_list.go
script.go
...
main.go
...
That said, here are my questions:
How would you solve this? Would you combine the video and engine packages? Redesign your program so that video no longer depends on engine?
How do you decide when it's appropriate to make a new package? Do you base it on functionality? Do you group it by category?
How much use do you make of the main package? I personally tend to get out of it as quickly as possible, maybe because I'm too used to OOP.
As these questions are rather broad and project-specific, I can only hope this is of any help:
Personally, I would try to create a third package on which both video and engine can rely. Depending on the project though, this might be a difficult thing to do, and they might need to be merged.
A new package is usually about one specific task. Depending on the project, this might be database I/O, including all models as well - but it might also be a package that's just about reading configuration files from the disk.
As I've built mostly web-apps, I use the main package to get things started: listening to ports, calling other functions, making sure database connections are closed properly, etc.
Example (not sure if helpful? ) :
I once had a package that was just about configurations (config), which referred to the rest of the packages (for some reason). The other packages however, depended on those configurations inside config. This is where the main package can come in handy: linking the config package with the other packages, by means of parameters.
The comment from VonC is also very useful and elaborate. It will probably help you more than this.