I have Go installed, setup, and running hello world; I followed these directions. My workspace is organized as follows:
gocode/
bin/
pkg/
src/
github.com/
my_username/
hello/
hello.go
anomalyzer/
algorithms.go
...
README.md
I would like to start using Go code from a forked GitHub repo, lytics/anomalyzer. How can I do this? I forked the repo and setup a local clone in github.com/anomalyzer/ as shown above. But from the github.com/anomalyzer/ dir I try go install and get the error message algorithms.go:5:2: cannot find package "github.com/drewlanenga/govector" in any of: ...(lists my GOPATH). It looks like I need to also clone the github.com/drewlanenga/govector, do I? Is there an automated way to get all the package dependencies?
To fetch remote packages, run the go get command. Because the go get command automatically fetches dependencies and does not fetch a package that already have have, you can run
go get github.com/lytics/anomalyzer
to get everything setup including the github.com/drewlanenga/govector package.
Related
I'm getting used to Go, and trying to understand how it works.
So I'm trying to run the test code from my repository zoonoo/go-ethereum, forked from the original repository ethereum/go-ethereum.
When I run go test . under the eth directory, I get the following error :
eth/api.go:37:2: use of internal package not allowed
37th line of eth/api.go is as follows : "github.com/ethereum/go-ethereum/internal/ethapi"
Does this mean when you fork a go repository, you have to change the path of all dependencies within the code to run the code?
Does Go package system support repository fork at all?
As illustrated in another Go project:
Cloning a fork
If you wish to work with fork of InfluxDB, your own fork for example, you must still follow the directory structure above. But instead of cloning the main repo, instead clone your fork. Follow the steps below to work with a fork:
export GOPATH=$HOME/gocodez
mkdir -p $GOPATH/src/github.com/influxdb
cd $GOPATH/src/github.com/influxdb
git clone git#github.com:<username>/influxdb
Retaining the directory structure $GOPATH/src/github.com/influxdb is necessary so that Go imports work correctly.
Replace InfluxDB name/URL by your project, and the same idea applies.
In your case, the GitHub fork is only there for you to push your contribution back to it, and to make Pull request from it.
It won't serve as a source for go get to work, since the packages wouldn't match your GitHub for repo URL.
This is because internal packages in go can only be imported by packages in the same directory root. It's kind of like package private classes in java. If you want to edit the code without having to rename all package imports you need to maintain the same folder structure that the package expects so if github.com/zoonoo/go-ethereum is in your $GOPATH rename the directory to github.com/ethereum/go-ethereum or create a symbolic link and work from the linked directory instead.
I want to start contributing to material-ui but before I submit a Pull Request I'd like to visually confirm that my changes have the desired effect. I followed the "install" page at material-ui.com and now I can run docs locally but I'm not sure what that does for me. I'd like to make a new barebones project that uses the material-ui that I have forked. Ideally it would use the material-ui that is on my local machine and not in my remote repo (this would allow me to make quick changes locally rather than having to push every time I want to see the consequences of a change). Is this possible?
You can use npm link to create a material-ui symbolic link inside node_modules that actually points to your forked version's physical folder. https://docs.npmjs.com/cli/link
Example:
cd ~/projects/material-ui # go into your forked directory
npm link # creates global link
cd ~/projects/my_project # go into your project directory
npm link material-ui # link-install the package
I need to import external package from github “github.com/xy/packageX” to MyProject/src/myProjcet.go. So I added import “github.com/xy/packageX” to myProject.go. If I run go build, I get:
myProject.go:9:2: import “github.com/xy/packageX”: cannot find package
So I have to run go get, and then go build.
Is there a way, how it can be built without using of go get? Or should I download it to MyProject/pkg and added this link to myProject.go? I am on Xubuntu 14.04.
If you don't want to add your go project dependency to the global GOPATH, you can vendor it. (go 1.6+ recommended: see "Vendor Directories")
Go to the package which uses that import, and add it as a submodule in a vendor sub-folder.
cd GOPATH/src/myproject/mypackage
git submodule add -- https://github.com/<user>/<repo> vendor/github.com/<user>/<repo>
cd vendor/github.com/<user>/<repo>
go install
cd ../../../..
go install
Note: that repo might have itself other dependencies, that you would need to add in a similar fashion (in the same vendor folder)
If your project is up to the repository, such as github,
When the initial "go install" will be "go get" even as packageX.
I want to fork a suggester for elasticsearch from Github.
I'm following the steps on the website, I'm asked to run the following code:
git://github.com/spinscale/elasticsearch-suggest-plugin.git
Which class shall I run it in ? and shall I create a new project for it or shall I run it in my current project?
I'm working with eclipse and play framework.
The only line where I see "git://github.com/spinscale/elasticsearch-suggest-plugin.git" at the GitHub elasticsearch-suggest-plugin page is:
If you want to work on the repository
Clone this repo with git clone git://github.com/spinscale/elasticsearch-suggest-plugin.git
Run: gradle clean assemble zip – this does not run any unit tests, as they take some time. If you want to run them, better run gradle clean build zip
Install the plugin: /path/to/elasticsearch/bin/plugin -install elasticsearch-suggest -url file:///$PWD/build/distributions/elasticsearch-sugges
So this line is about cloning locally that repo to run the plugin.
It is not about a "class to run". It is an address that the DVCS (Distributed Version Control System) Git must use to clone the repo.
git clone git://github.com/spinscale/elasticsearch-suggest-plugin.git
I've set up my github account and I'm ready to go. I'm trying to follow these instructions, for setting up an API wrapper for an iPhone project using Soundcloud, but I'm a bit lost:
1. Go to your project directory.
2. Add the Cocoa API Wrapper as a Git Subproject
git submodule add git://github.com/soundcloud/cocoa-api-wrapper.git SoundCloudAPI
3. Update the Subprojects (the API Wrapper includes the NXOAuth2Framework as a subproject)
git submodule update --init --recursive
My questions are: Where do I go in my project directory? The same level as the XCode project file? Also, the command in #2 doesn't really work for me. I get the error:
fatal: Not a git repository (or any of the parent directories): .git
Am I missing something?
These instructions assume that you're using git for your project. And according to the error message, you don't. So, probably, you want at least to git init your project, but probably you will want more.
As for where to go in your project — where you want the SoundCloudAPI to reside. Which will be created in the current directory.