Does not make sense that I have to have files before import - github

How do I import an external package from scratch?
I've written a library package in Go and testing to distribute through github. I am following http://golang.org/doc/code.html and using mac but getting error message
cmd I put is following.
$ mkdir $HOME/go
$ export GOPATH=$HOME/go
$ export PATH=$PATH:$GOPATH/bin
$ mkdir -p $GOPATH/src/github.com/user
$ mkdir $GOPATH/src/github.com/user/project
Then I put
$ go get github.com/user/project
Still errors with go install
can't load package: package github.com/golingorg/goling: no Go source files in /Users/user_name/go/src/github.com/user/project
I do not understand why we need files to import an external package in Go. External package means that I get something and create files from the external package.
My question is how I import an external package from scratch. Most of documents just say something like
go get github.com/yasushi-saito/fifo_queue
this gives me "$GOPATH not set."
I am getting frustrated setting up the environment for "go get" to work, as a beginner. Thanks a lot in advance.
Summary
How do I import an external package from scratch?

Go is a static type language thus it needs to resolve any reference to external package at compile time. The "go" tool expects the source of external packages in locally accessible path thus you need to use "go get" to download them.
From what you described, you probably did not set the GOPATH. Use ECHO $GOPATH to check if it is set correctly.
For my GO project, I normally use GOPATH as workspace, similar to virtualenv in Python or rbenv/rvm in Ruby. Let say my project "myproject" has root at /projects/myproject, my source file will be located at /projects/myproject/src/myproject and there is an import of "github.com/user/project", then
> cd /projects/myproject
> export GOPATH=`pwd` # or export GOPATH=/projects/myproject
> go get github.com/user/project
After "go get" command, the source of "github.com/user/project" will be downloaded to /projects/myproject/src/github.com/user/project.
When you use "go build" or "go install" then, it will compile as the external packages is in the $GOPATH/src folder.
If you install Go in the default folder, you need to include Go installed bin folder in the PATH environment variable. After that GOPATH is the other environment variable you need for "go" tool to work.

That's how I done it:
1. Setup your workspace first
mkdir $HOME/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
2. Create the project
mkdir -p $GOPATH/src/github.com/user
mkdir $GOPATH/src/github.com/user/hello
touch $GOPATH/src/github.com/user/hello/hello.go
3. Install it
go install github.com/user/hello
4. Run it
cd $GOPATH/bin
./hello
I used the following vagrant image: https://github.com/dcoxall/vagrant-golang

From the help output for go get, it says:
By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages.
When you created the $GOPATH/src/github.com/user/project directory prior to running go get, it assumed that the package had already been downloaded so skipped to the step of trying to build and install the package. That failed because the directory contained no Go source files.
So the simple fix is to not create the folder associated with the package you are trying to download: go get will do that for you.

Related

How to define rule file in debian packaging of a project which have a make file to build from source?

I'm new to stackoverflow so correct me if I made any mistake in providing the details.
So I'm trying to make a deb file for Apache-Age, and going by the documentation, if we try to install AGE from source then we can simply do it by :
make install
I have setup the basic directory structure by dh_make and have made the control file with proper dependencies, then comes the rule file.
So I went through 2 different extensions of postgreSQL :
postgresql-q3c
Postgis
And tried to replicate the same for apache-age, and tried to build by following commands
dpkg-buildpackage -rfakeroot -b
dpkg-buildpackage -nc -i
the build was giving some errors and warning but a deb file was generated.
The deb file installed properly but age-extension was not installed in PostgreSQL.
It's probably because the age was not building properly from source using make command as specified in the rule file.
Is there any good resource or how to make rule file ?
I tried following this answer, but got stuck here.
I found a PDF but didn't understand the build process.
This might be a naive way but it works for me:
Clone the repo and cd to it
Run the dh_make_pgxs command to make the debian build directory structure.
The you need to make changes to pgversion, control/control.in, changelog, copyright and rule files.
If you are just trying to use the make file to build the package then the rule file can be as simple as:
#!/usr/bin/make -f
%:
dh $#
Then simply run the build command as before.

TNS command not found after installing NativeScript

I updated NPM and Node before installing NativeScript, without errors I might add, but when I attempt to create a new project using tns create MyProjectName, I get the error tns command not found.
After much reading, I'm getting the feeling it has something to do with my PATH.
This is what is outputted in terminal during the NativeScript install regarding TNS:
sudo npm install -g nativescript --unsafe-perm
/Users/martingeldart/.npm-global/bin/tns -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
/Users/martingeldart/.npm-global/bin/nativescript -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
...
If I run echo $PATH, this is what outputs:
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/bin/lib/node_modules/nativescript/bin
Which looks really odd to me but I'm no command line expert by any means. In fact, I'm incredibly inexperienced with the whole command line system.
Why am I not able to access the tns command? What is going on with that PATH I echoed?
MacOSX
Between version of npm the location of the global package moved location in the OS. Since the installation has moved the terminal does not know where to find the command. The PATH variable is used to tell the terminal where all the command may be located. In this case this seems a standard.
Now the best way to access command from an installed package is to use npx which is included by default with the new installation of npm.
https://docs.npmjs.com/downloading-and-installing-packages-globally
npx tns
# In your case
npx tns create MyProjectName
There 2 other ways to resolve this.
Either your global package folder is not set up correctly.
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Add the bin folder where nativescript was install to your path manually (usually in .bash_profile), open a new terminal.
I use nativescript for various project and I have a suggestion for package management. Usually I avoid installing global package because in case of multiple project there may be conflict between version if some project are updated and other not.
I usually create a folder with the version I am installing. Go to the folder, npm init and install locally the package.
mkdir nativescript-project-6-0
cd nativescript-project-6-0
npm init
npm i --save nativescript
Now I have a fix version to work with and can create other project with the same version even if I have other project with newer version of the tool or lib. Now in nativescript-project-6-0 I create my project.
npx tns create MyProjectName
This should create a folder nativescript-project-6-0/MyProjectName. All set and ready to go. Remember that is is always a good idea to use npx in this case since we want to use the local package.

Build libraries in external folder of AOSP source code

I noticed that a simple
$ . build/envsetup.sh
$ lunch
$ aosp_hammerhead-eng
$ make -j16
Would not build also the external libraries in the ./external folder.
How am I supposed to build source code in such folder?
In particular, I am modifying source code in the libselinux in ./external/selinux/libselinux/src/
Thanks!
I found out that, by using the mm command, it is possible to build all of the modules in the current directory.
So, if you are in ./external/selinux/libselinux/ you can build all code inside such directory just by typing the command mm.
I also found that the same code I was modifying inside the ./external/selinux/libselinux/ is also located in ./external/libselinux/. However, this directory is linked to the make -j16 command.

How to submit a package to PyPI under a different user than my ~/.pypirc

As far as I can tell from the docs, unlike with say git and .gitignore files, setuptools will only look in your $HOME directory for a .pypirc file.
Mostly I am submitting as 'myself', but now I want to submit a specific project via my employer's dev team account.
setup.py register --help doesn't seem to indicate any way to supply a username/password other than the one from my ~/.pypirc
There's the setup.cfg file which could appear in my project root, but it seems that only allows to specify args accepted by the command, so same as above.
Same for .pydistutils.cfg (?)
Surely I can't be the only one - what's the usual way to do this?
I found a workaround, which is to use https://pypi.python.org/pypi/twine
After installing twine I was able to create a project-specific .pypirc file in the project root, containing the company username/password.
Before using twine you have to generate the package using setup.py though, so the procedure is (from your project root):
$ python setup.py sdist
$ twine register --config-file=./.pypirc dist/*
$ twine upload --config-file=./.pypirc dist/*

Simple Unix question - Configure

I'm using Solaris 10, ksh. Whenever I do a ./configure, I get the error "ksh: ./configure: not found"
When I do a "where configure", nothing is found.
How do I "install configure"?
./configure means that you want to run an executable called configure in your current directory (signified by a .). I'm guessing you're trying to build and install from source, and the directions say to do the standard ./configure; make; make install. You should do that from the top-level directory of the source you downloaded and unpacked:
$ cd /path/to/source
$ ./configure
$ make
$ make install
"./configure" means "run the program configure from the current directory". That is, you need to cd to the directory that configure lives in before attempting to run it like that.
As for where configure might be found, it's usually at the root of whatever source package you're trying to build.
I'm not a Solaris guy, but the configure script should be within your current directory before you execute it. I am assuming you're trying to build something. If it's a project of your own, take a look at GNU autoconf. (I have no idea if this a part of Solaris or not.) It's part of M4.
If it's a project that you downloaded, untar/unzip/unpack it and then cd to its directory before running the configure script.
I had to run a command for another directory; and then that popped everything up :)
In case someone else comes across this specific issue, I'm trying to install the Perl-Php plugin on a Solaris machine. Initially, there is no configure file; instead you have to find where your "phpize" is located -- for me it was /opt/webstack/php/5.2/phpize, run it while you are still in the "perl-php-plugin" folder, and then configure will appear.
Then you can ./configure :)
Thanks to everyone who responded.