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 9 months ago.
Improve this question
I'm starting with GO, and I want to create a virtualenv like in Python (to store import modules at the project directory itself), I read in GO's doc https://go.dev/doc/tutorial/workspaces and understand that GO's Create the workspace is what i'm doing need. But when I do, it doesn't work. Like in the attached image, after "go mod init .../hello_go" complete, then "go work init ./hello_go" and something wrong.
I don't understand what is the problem?
The problem is that the go.work file is supposed to be at the root of your project and point to subdirectories containing a go.mod file.
The error is telling you that there is no directory ./hello_go containing a go.mod file. This is correct because you have initialized your module also at the root level.
If you have only a single module, you don't need to create a workspace. You can create your module at root level like you did, and then use go mod to manage your dependencies for that particular module.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 18 days ago.
Improve this question
i have enabled the go modules integration according to this docs .
https://www.jetbrains.com/help/go/create-a-project-with-go-modules-integration.html#enable-go-modules-in-a-project
but yet again as you can see in image below . goland keep throwing error on some code i have
as you can see in image i have that execlise package but it keep giving error . not only that i have some error on other files
That happens sometimes with IDEs, from my experience it may happen because of at least three reasons.
first: the differences between package versions in your go.sum, you should empty the go.sum and run go mod tidy command.
Second: the version you’re using is older or newer than what you’re expecting, so the package does not support these methods or didn’t include them. so you should set the exact version of the package. (I suggest you read the documentation of the package in this case)
Third: your IDE has got some problems with the caches. for solving this: you should click on file -> invalidate caches to rebuild your IDE caches.
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 1 year ago.
Improve this question
For example, I have a project with following structure:
hello
- packageA
- subDirA
- Afile1.go
- Afile2.go
- packageB
- Bfile.go
- Bfile2.go
- packageC
- main.go
- subdirC
- xx.json
- packageD
-xx.go
How can I build them and get an executable file xxx on Linux platform, so that I can directly call them by ./xxxx?
Short answer: go build
You can run go help build to learn more on how to use it. For example, it's possible that you'll want to provide a specific path to go build, or build with ./.... It depends on the exact layout of your project.
I strongly recommend you to read some official Go documentation pages first:
Getting started with Go
How to write Go code
Work through the examples in these pages (and the other pages they lead to); this will answer most of your questions. The second link, in particular, talks about properly using go build and go install to build your projects.
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 2 years ago.
Improve this question
I'm currently learning golang, I'm using windows
I've installed VSCode's Go extension.
When I hover over new package added by goimports in VSCode, I get the error
could not import io/ioutil (cannot find package "io/ioutil" in any of
C:\Users\<username>\go\src\io\ioutil (from $GOROOT)
C\src\io\ioutil (from $GOPATH)
\Users\<username>\go\src\io\ioutil (from $GOPATH))compiler
I have installed go in C:\Users\<username>\go. When I check the directory C:\Users\<username>\go\src\io\ioutil it exists(the ioutil.go file is present as well).
It's a package in go's standard library, yet it is not detected by the extension. I have to reload VSCode for it to work. Also when I compile the code using go build or go run command, the code compiles.
You should install Go somewhere else than C:\Users\<username>\go as that is also default GOPATH. Having GOPATH (a directory where your user modules are installed) in same place as GOROOT (a directory where Go itself is installed) will cause a lot of different problems and confuse many tools.
Either completely remove current installation and re-install Go somewhere else (recommended) or point your GOPATH somewhere else.
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
I'm looking at a Zend Framework 3 application on a server, and I don't see any composer.json file in the root.
I'm trying to download the entire application and add it to GitHub, but I don't want to download the vendor files (which I assume I can just download after running composer) but I'm not seeing any composer.json file to know what packages are external libraries, etc...
Does anybody know where the composer file is or what is the right way to go about this?
This is what's on the root directory
Long story short: it was deleted.
Short story long: you should recreate the composer.json file from the vendor/composer/installed.json file. See this thread for more information.
You shouldn't just download the original composer.json from the repo as #Alain Pomirol suggests, because there may be additional packages installed.
Also, temporarily include the vendor directory in the git repository. When you're ready with the composer.json file install dependencies again and check via git diff if that person didn't make any forbidden modifications to the vendor files. I've seen that so many times before…
A normally installed application must present a composer.json file in the root. You can find the model here : https://github.com/zendframework/ZendSkeletonApplication
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've created a Ruby gem with the traditional 'lib' structure, but I also have another directory, say 'more' at the same level as 'lib'. However I cannot seem to access any of the methods in the 'more/*.rb' files. Can anyone tell me what needs to be done?
PS - I know from /Shopify/Liquid that they have a similar situation with 'lib' and 'performance' dirs, and there is a 'performance/shopify/liquid.rb' file and also a 'lib/performance' dir but for the life of me I cannot figure out how all that fits together. If I could resolve that then I think it would also be applicable to my solution.
From liquid's gemspec:
s.require_path = "lib"
It doesn't look like /performance is used in the gem, it's only for benchmarking and testing.
liquid/lib doesn't appear to have a performance directory. Looks like the word 'performance' is only used in the Rakefile really. Again for testing.
You can do this as well, no magic needed, it's just another directory.
If you want to include another directory as a library path, then alter the gemspec require_path value.