{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Install\n", "Download: https://golang.org/dl/\n", "## Jupyter\n", "https://github.com/gopherds/gophernotes\n", "```\n", "docker pull dwhitena/gophernotes:latest\n", "docker run --name gophernotes --net host -d dwhitena/gophernotes:latest\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# System default" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ii golang-src 2:1.0.2-1.1 amd64 Go programming language compiler - source files\r\n" ] } ], "source": [ "dpkg -l golang-{go,src} | grep ^ii" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# GOROOT - for program" ] }, { "cell_type": "code", "execution_count": 73, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/anaconda3/bin/:/root/go/bin\r\n" ] } ], "source": [ "echo export GOROOT=/root/go >> $HOME/.profile\n", "echo export PATH=$PATH:$GOROOT/bin >> $HOME/.profile\n", "source $HOME/.profile\n", "echo $PATH" ] }, { "cell_type": "code", "execution_count": 74, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/root/go\r\n", "/root/go/bin/go\r\n", "go version go1.6.3 linux/amd64\r\n" ] } ], "source": [ "go env GOROOT\n", "which go\n", "go version" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# GOPATH - for data" ] }, { "cell_type": "code", "execution_count": 75, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [] } ], "source": [ "echo export GOPATH=$HOME/go_work:$HOME/Dropbox/go >> $HOME/.profile\n", "source $HOME/.profile" ] }, { "cell_type": "code", "execution_count": 77, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mesg n\r\n", "export GOROOT=/root/go\r\n", "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/anaconda3/bin/:/root/go/bin\r\n", "export GOPATH=/root/go_work:/root/Dropbox/go\r\n", "\r\n", "/root/go_work:/root/Dropbox/go\r\n" ] } ], "source": [ "cat $HOME/.profile | tail -n -4\n", "echo ''\n", "echo $GOPATH" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Coding" ] }, { "cell_type": "code", "execution_count": 92, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/root/go_work\r\n", "total 12\r\n", "drwxr-xr-x 2 root root 4096 Aug 10 15:31 bin\r\n", "drwxr-xr-x 3 root root 4096 Aug 10 14:55 pkg\r\n", "drwxr-xr-x 4 root root 4096 Aug 10 14:55 src\r\n", "/root/Dropbox/go\r\n", "total 8\r\n", "drwxr-xr-x 3 root root 4096 Aug 10 16:01 src\r\n" ] } ], "source": [ "string=$GOPATH\n", "set -f # avoid globbing (expansion of *).\n", "array=(${string//:/ })\n", "for i in \"${!array[@]}\"\n", "do\n", " echo \"${array[i]}\"\n", " ls -l \"${array[i]}\"\n", "done" ] }, { "cell_type": "code", "execution_count": 93, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [] } ], "source": [ "mkdir -p /root/Dropbox/go/src/github.com/fzinfz/hello" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "go install github.com/fzinfz/hello" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Bash", "language": "bash", "name": "bash" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".sh", "mimetype": "text/x-sh", "name": "bash" } }, "nbformat": 4, "nbformat_minor": 0 }