A fontsize too small?
Feb 25
Goodbye XML
Feb 6
I’m leaving you XML. I’m just not into you anymore. I don’t think I ever was…I just used you. Sorry.
Why? You’re just too damn hard to read and you give me a headache. I always have to check if you’re well-formed and, frankly, most of the time, you’re not.
It’s not because you have only one root. No, it’s not. You’re always so damn verbose…and you use tabs everywhere we go and who picks those up? I do. That’s who.
Well, it stops today.
Yes, there is someone else.
Behold the Canadian NoProrogue Protests as a Cluster Map:
Today I’m building a cluster map using the way cool CartographerJS thematic JavaScript library. The library greatly simplifies the creation of “heat map” style overlays for Google Maps. In order to follow along, you will need to be familiar with GMap2 and JavaScript.
To create a cluster map, you need to include a few libraries:
- Google Maps GMap2 API – Makes maps from divs
- RaphaelJS – Library to draw vector graphics
- CartographerJS
Download Raphael and Cartographer somewhere webby and then include them in the head of your html page with your GMap API key URL (Google provides this):
10 11 12 | <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAkWkoIqBrrWjZm_w3j6xq2hSa3-TS0yNMl32jU2eh6AwgDkL60hSCs7jQoaWypWYc5VCS-RKonhKskg" type="text/javascript"></script> <script type="text/javascript" language="javascript" src="raphael-min.js"></script> <script type="text/javascript" language="javascript" src="cartographer.min.0.3.js"></script> |
The data that we are going to plot comes from the NoProrogue.ca protest actions that took place on 23 Jan 2010 across Canada. This dataset was converted from the early estimates produced by Ian Capstick in his Globe and Mail article.
9 | <script type="text/javascript" language="javascript" src="http://www.kelvinwong.ca/code/html/protest_maps/protest_data.js"></script> |
The data is a simple array packed with object literals. The important parts of the object literals are: the latitude of the point (lat), the longitude of the point (lng), the value to use when plotting (val) and the label to use on the callout (label):
1 2 3 4 | var protest_data = [ {lat:43.656076, lng:-79.380279, val:9000, label:"Toronto: 9000, Police place at 7000 - organizers claim 15,000"}, // Other object literals here!!! ]; |
If you tried out the Hello World demo from the GMap2 documentation, then this code should look familiar. The plan is to place an empty div on the page and fill it with a map and an overlay dynamically written with JavaScript. Here is the target div:
16 17 | <body onload="initialize()" onunload="GUnload()"> <div id="map" style="width: 650px; height: 450px"></div> |
And here is the code that draws the map then places the map object into the cartographer object:
19 20 21 22 23 24 25 26 27 28 29 30 31 | function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(61.856149,-95.625), 3); map.setUIToDefault(); var mapoptions = { colorize:"#fff", colorizeAlpha:0.1 }; var cartographer = Cartographer( map, mapoptions ); var options = { color:"red", enableGrid:false }; cartographer.cluster( protest_data, options ); } } |
The mapoptions object literal specifies the colour of the overlay (colorize) and the opacity of the overlay (colorizeAlpha). If the opacity is set to 1.0 you won’t be able to see the map underneath, so set it to a sane value like 0.1 or 0.3. We pass that object literal and the Google map object as parameters to initialize the cartographer object.
The options object literal is used to construct a cluster map on the overlay. In this case I wanted to specify the colour of the data points (color) and to disable the grid (enableGrid). There are many other settings you can specify based on your own needs. When you are ready to draw your overlay, pass the options object and the data as parameters into the cluster method of the cartographer object. Ecco fatto!
You can view the file without the iframe!
Saturday night compilation
Jan 23
It’s another Saturday night at 9pm. Time to compile some code, right? Right?
So, before I start doing that, I’m on IM chatting with an old friend of mine in Toronto. He’s like: “What are you doing sitting in front of your computer on a Saturday night? HUH?”
Without blinking: “I’m building Cassandra this newish database thing…blah blah blah…”
So yeah he’s busy ignoring me by the time I get around to typing about Thrift. His point is that I’m playing with computers on a Saturday night, but on the other hand, he’s working on a press deadline (and it’s midnight in Toronto). What’s worse? I donno.
This is a short post showing you how to install the superdooper Key-Value Store Cassandra version 0.5.0 on a Macbook running OS X Leopard 10.5.8 (yeah I know, I should upgrade to Snow Leopard sometime). Cassandra 0.5 promises to be peppier than the 0.4 version and at this point it hasn’t been released yet, but I’m impatient, so I’m setting up a ‘one-node cluster’ for fun.
Cassandra 0.5.0 was released on 25 Jan 2010.
You will need to ensure that you are running Java 1.6. Since Java 1.5 is the default on Mac OS X, you need to set up a couple of environment variables. I just put the following into my .bash_profile file using vim.
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
export PATH=$JAVA_HOME/bin:$PATH
Now source the file (if you haven’t already done that) and examine your set-up.
Trinity:~ kelvin$ source .bash_profile
Trinity:~ kelvin$ env | grep JAVA_HOME
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
Trinity:~ kelvin$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)
Trinity:~ kelvin$ xcodebuild -version
Xcode 3.1.2
Component versions: DevToolsCore-1148.0; DevToolsSupport-1102.0
BuildVersion: 9M2621
Yeah, my xcode is a bit old too. So, once that is done, download Cassandra. I am going to use the tag in the Subversion repository for the 0.5.0 release.
Trinity:code kelvin$ svn co https://svn.apache.org/repos/asf/incubator/cassandra/tags/cassandra-0.5.0/ cassandra-0.5.0
...svn key gibberish redacted...
A cassandra-0.5.0/NOTICE.txt
cassandra-0.5.0/src/java/org/apache/cassandra/io/StreamRequestVerbHandler.java
...checkout redacted...
A cassandra-0.5.0/build.xml
U cassandra-0.5.0
Checked out revision 902040.
Trinity:code kelvin$ cd cassandra-0.5.0
Trinity:cassandra-0.5.0 kelvin$ pwd
/Users/kelvin/code/cassandra-0.5.0
Trinity:cassandra-0.5.0 kelvin$
Cassandra expects some folders to be available, so we will need to set them up (per the instructions in the README file). First of all, check the file conf/storage-conf.xml and make sure that these folders exist before you do anything else.
<CommitLogDirectory>/var/lib/cassandra/commitlog</CommitLogDirectory>
<DataFileDirectories>
<DataFileDirectory>/var/lib/cassandra/data</DataFileDirectory>
</DataFileDirectories>
<CalloutLocation>/var/lib/cassandra/callouts</CalloutLocation>
<StagingFileDirectory>/var/lib/cassandra/staging</StagingFileDirectory>
If they do not exist, you will have to make them (careful with the whoami command in backticks):
Trinity:cassandra-0.5.0 kelvin$ sudo mkdir -p /var/log/cassandra
Password:
Trinity:cassandra-0.5.0 kelvin$ sudo chown -R `whoami` /var/log/cassandra
Trinity:cassandra-0.5.0 kelvin$ sudo mkdir -p /var/lib/cassandra
Trinity:cassandra-0.5.0 kelvin$ sudo chown -R `whoami` /var/lib/cassandra
For logging, Cassandra expects that a system.log file is available. Check the conf/log4j.properties file to check where it expects a log file. It should be similar to this:
log4j.appender.R.File=/var/log/cassandra/system.log
When you start Cassandra for the first time it will start the log file.
I used ‘ant‘ to build Cassandra. Make sure that you are in the root of the Cassandra directory. I have a lot of crap in my Java classpath, so I will temporarily exclude it.
Trinity:cassandra-0.5.0 kelvin$ ant -noclasspath
Buildfile: build.xml
build-subprojects:
init:
[mkdir] Created dir: /Users/kelvin/code/cassandra-0.5.0/build/classes
[mkdir] Created dir: /Users/kelvin/code/cassandra-0.5.0/build/test/classes
[mkdir] Created dir: /Users/kelvin/code/cassandra-0.5.0/src/gen-java
check-gen-cli-grammar:
gen-cli-grammar:
[echo] Building Grammar /Users/kelvin/code/cassandra-0.5.0/src/java/org/apache/cassandra/cli/Cli.g ....
build-project:
[echo] apache-cassandra-incubating: /Users/kelvin/code/cassandra-0.5.0/build.xml
[javac] Compiling 247 source files to /Users/kelvin/code/cassandra-0.5.0/build/classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
build:
BUILD SUCCESSFUL
Total time: 13 seconds
Trinity:cassandra-0.5.0 kelvin$
Now the moment of truth!
Trinity:cassandra-0.5.0 kelvin$ bin/cassandra -f
Listening for transport dt_socket at address: 8888
INFO - Saved Token not found. Using 25907362644306974147256376871662350143
INFO - Starting up server gossip
INFO - Cassandra starting up...
Okay, Cassandra is now waiting for us to do something, so we can open up another Terminal window (Cmd+N) and try the test described in the README file:
Trinity:cassandra-0.5.0 kelvin$ bin/cassandra-cli --host localhost --port 9160
Connected to localhost/9160
Welcome to cassandra CLI.
Type 'help' or '?' for help. Type 'quit' or 'exit' to quit.
cassandra> set Keyspace1.Standard1['jsmith']['first'] = 'John'
Value inserted.
cassandra> set Keyspace1.Standard1['jsmith']['last'] = 'Smith'
Value inserted.
cassandra> set Keyspace1.Standard1['jsmith']['age'] = '42'
Value inserted.
cassandra> get Keyspace1.Standard1['jsmith']
=> (column=last, value=Smith, timestamp=1264159272089)
=> (column=first, value=John, timestamp=1264159260000)
=> (column=age, value=42, timestamp=1264159282593)
Returned 3 results.
cassandra>
Okay, we now have stored and retrieved some data. In the next installment I’ll try to get Thrift running!
PHP 5.2.12 has a bug that will stop your installation:
/bin/sh /Users/kelvin/phpsource/php-5.2.12/libtool --silent --preserve-dup-deps --mode=compile gcc ...includes redacted... -no-cpp-precomp -I/usr/local/php5/include -g -O2 -c /Users/kelvin/phpsource/php-5.2.12/ext/standard/dns.c -o ext/standard/dns.lo
In file included from /usr/include/arpa/nameser.h:59,
from /Users/kelvin/phpsource/php-5.2.12/ext/standard/dns.c:62:
/usr/include/arpa/nameser8_compat.h:304: error: conflicting types for ‘HEADER’
/usr/include/arpa/nameser_compat.h:99: error: previous declaration of ‘HEADER’ was here
make: *** [ext/standard/dns.lo] Error 1
Trinity:~ kelvin$
Two header files (nameser8_compat.h & nameser_compat.h) both try to define a struct named HEADER. No can do. According to the PHP bug tracker, “NEVER ever include nameser_compat.h, it’s included in various ways in different OSes by nameser.h if needed”
Doh!
So how do we go about fixing this? The easiest thing to do is to install the older PHP 5.2.11 or the HEAD from the 5.2 branch. If you are adventurous or obsessive-compulsive you can also replace these two files with the patched copies:
I had to install mcrypt on a new virtual private server running CentOS 5.3 and Plesk 9.2. We didn’t want to do compile it, so we used yum to install it. The libmcrypt library is used to provide cryptographic functions and we are planning to use them in our php scripts. Let’s try to install it…
[root@nechi etc]# cat /etc/redhat-release
CentOS release 5.3 (Final)
[root@nechi etc]# uname -a
Linux nechi.local 2.6.18-028stab064.7 #1 SMP Wed Aug 26 13:11:07 MSD 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@nechi etc]# php -v
PHP 5.2.11 (cli) (built: Oct 7 2009 08:45:24)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
[root@nechi etc]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* atomic: www5.atomicorp.com
* base: mirror.nic.uoregon.edu
* updates: mirror.chpc.utah.edu
* addons: centos.mirror.nac.net
* extras: mirror.stanford.edu
plesk | 951 B 00:00
atomic | 951 B 00:00
base | 2.1 kB 00:00
updates | 1.9 kB 00:00
addons | 951 B 00:00
extras | 1.1 kB 00:00
repo id repo name status
addons CentOS-5 - Addons enabled : 0
atomic CentOS / Red Hat Enterprise Linux 5 - at enabled : 709
base CentOS-5 - Base enabled : 3,348
extras CentOS-5 - Extras enabled : 290
plesk Plesk Server Administrator enabled : 193
updates CentOS-5 - Updates enabled : 363
repolist: 4,903
[root@nechi etc]#
The easiest way to do this is to use the php-mcrypt rpm package. That package has some dependencies. Earlier, I had installed libmcrypt so I figured I could just install the php-related rpm and I’d be done:
[root@nechi etc]# yum install php-mcrypt
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* atomic: www5.atomicorp.com
* base: mirror.nic.uoregon.edu
* updates: mirror.chpc.utah.edu
* addons: centos.mirror.nac.net
* extras: mirror.stanford.edu
Excluding Packages from Plesk Server Administrator
Finished
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package php-mcrypt.x86_64 0:5.2.11-2.el5.art set to be updated
--> Processing Dependency: libltdl.so.3()(64bit) for package: php-mcrypt
---> Package php-mcrypt.i386 0:5.2.11-2.el5.art set to be updated
--> Processing Dependency: libltdl.so.3 for package: php-mcrypt
--> Processing Dependency: libc.so.6(GLIBC_2.4) for package: php-mcrypt
--> Processing Dependency: libc.so.6 for package: php-mcrypt
--> Processing Dependency: libmcrypt.so.4 for package: php-mcrypt
--> Processing Dependency: libc.so.6(GLIBC_2.1.3) for package: php-mcrypt
--> Processing Dependency: libc.so.6(GLIBC_2.0) for package: php-mcrypt
--> Running transaction check
---> Package libtool-ltdl.i386 0:1.5.22-6.1 set to be updated
---> Package php-mcrypt.i386 0:5.2.11-2.el5.art set to be updated
--> Processing Dependency: libmcrypt.so.4 for package: php-mcrypt
---> Package glibc.i686 0:2.5-42 set to be updated
---> Package libtool-ltdl.x86_64 0:1.5.22-6.1 set to be updated
--> Finished Dependency Resolution
php-mcrypt-5.2.11-2.el5.art.i386 from atomic has depsolving problems
--> Missing Dependency: libmcrypt.so.4 is needed by package php-mcrypt-5.2.11-2.el5.art.i386 (atomic)
Error: Missing Dependency: libmcrypt.so.4 is needed by package php-mcrypt-5.2.11-2.el5.art.i386 (atomic)
[root@nechi etc]#
Oh great, it’s 1am on a Saturday night and my new OS hates me (digression: this speaks volumes).
[root@nechi etc]# yum list installed | grep mcrypt
libmcrypt.x86_64 2.5.8-4.el5.centos installed
[root@nechi etc]# ldconfig -p | grep libmcrypt.so.4
libmcrypt.so.4 (libc6,x86-64) => /usr/lib64/libmcrypt.so.4
[root@nechi etc]# find / -name libmcrypt.so.4
/usr/lib64/libmcrypt.so.4
[root@nechi etc]# ls -la /usr/lib64/libmcrypt.so.4
lrwxrwxrwx 1 root root 18 Dec 6 00:25 /usr/lib64/libmcrypt.so.4 -> libmcrypt.so.4.4.8
[root@nechi etc]# yum install libmcrypt-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* atomic: www5.atomicorp.com
* base: mirror.nic.uoregon.edu
* updates: mirror.chpc.utah.edu
* addons: centos.mirror.nac.net
* extras: mirror.stanford.edu
Excluding Packages from Plesk Server Administrator
Finished
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package libmcrypt-devel.x86_64 0:2.5.8-4.el5.centos set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================
Installing:
libmcrypt-devel x86_64 2.5.8-4.el5.centos extras 10 k
Transaction Summary
=========================================================================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 10 k
Is this ok [y/N]: y
Downloading Packages:
libmcrypt-devel-2.5.8-4.el5.centos.x86_64.rpm | 10 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libmcrypt-devel [1/1]
Installed: libmcrypt-devel.x86_64 0:2.5.8-4.el5.centos
Complete!
[root@nechi etc]# yum install php-mcrypt
So can you guess what happened next? The library was found the next time I tried to install it, right? Of course not. It still couldn’t find the stupid library. So Google and I had a talk and it turns out that you need to be really specific about your package (a good general rule in most situations) if you have a 64-bit machine.
[root@nechi etc]# yum install php-mcrypt.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* atomic: www5.atomicorp.com
* base: mirror.nic.uoregon.edu
* updates: mirror.chpc.utah.edu
* addons: centos.mirror.nac.net
* extras: mirror.stanford.edu
Excluding Packages from Plesk Server Administrator
Finished
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package php-mcrypt.x86_64 0:5.2.11-2.el5.art set to be updated
--> Processing Dependency: libltdl.so.3()(64bit) for package: php-mcrypt
--> Running transaction check
---> Package libtool-ltdl.x86_64 0:1.5.22-6.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================
Installing:
php-mcrypt x86_64 5.2.11-2.el5.art atomic 27 k
Installing for dependencies:
libtool-ltdl x86_64 1.5.22-6.1 base 37 k
Transaction Summary
=========================================================================================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 64 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): php-mcrypt-5.2.11-2.el5.art.x86_64.rpm | 27 kB 00:00
(2/2): libtool-ltdl-1.5.22-6.1.x86_64.rpm | 37 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------
Total 76 kB/s | 64 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libtool-ltdl [1/2]
Installing : php-mcrypt [2/2]
Installed: php-mcrypt.x86_64 0:5.2.11-2.el5.art
Dependency Installed: libtool-ltdl.x86_64 0:1.5.22-6.1
Complete!
[root@nechi etc]#
OMFG. Hey, did I mention that it is a Saturday night?
[root@nechi etc]# php -r "echo phpinfo();" | grep "^mcrypt"
mcrypt
mcrypt support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
[root@nechi etc]#
PHP makes me cry
Nov 27
4am: editing crufty code. lots of logic mixed up in the html old school style. Across the room a pile of three HP servers that need OSes catcalling: “I think I need a rebooty…”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // TODO: Clean this input //$tpar= $_GET[parent]; $tpar= intval($_GET['parent']); // TODO: Why are we putting a date into the server array??? $SERVER['$today']= date('y-m-d'); // TODO: Why are we storing a negative integer value as a string??? $colname_res_fillContent = "-1"; if (isset($_GET['parent'])) { // TODO: Check this input //$colname_res_fillContent = (get_magic_quotes_gpc()) ? $_GET['parent'] : addslashes($_GET['parent']); $colname_res_fillContent = intval($_GET['parent']); } // TODO: Why are we storing a negative integer value as a string again??? $today_res_fillContent = "-1"; if (isset($SERVER['$today'])) { // // TODO: didn't we set this??? why are we doing this??? why not set the date here??? // $today_res_fillContent = (get_magic_quotes_gpc()) ? $SERVER['$today'] : addslashes($SERVER['$today']); } |
So it turns out that my blog post on my experience completing a BC “out of province” vehicle inspection is ranking in the top ten results on Google for those keywords. In my opinion, that is a failure of the BC government. It should be straightforward for citizens in this province to find information on how to register a car from a different province. It was difficult enough for me to find this information and I’m a university-trained informatics nerd.
My car was from Ontario. It was about 20 years old and it was going to be driven in Victoria, so it didn’t need an AirCare certificate.
The way I got my car registered in BC was simple. I took my car to a local mechanic who could do the inspection (Parkside Motors – I recommend them if you need a good mechanic in Victoria BC). The car failed but Andrew pointed out how it failed and offered options to get it to pass. The fixes were simple: a new muffler, a rear light, two new tires, etc. After I made the improvements, I brought the car back to the same place and they re-inspected it (for no additional charge) and then gave me two-copies of the certificate. You keep one copy in the car and one copy you give to ICBC. That’s it if you live in Victoria.
The list of things that are checked are found on the form. My main concern was failing the test and then having to pay twice for the inspection, but it turns out that it is pretty standard in the industry to offer a second inspection at no charge if you go back to the same place. Just ask them.
Google released a new programming language named GO that offers the benefits of a dynamic language like Python with the speed of a compiled language like C/C++. In this walkthrough, I’m going to be installing the Google Go programming language on my Mac.
To get started, make sure that you have Python and Mercurial installed on your Intel Mac (PowerPC is not supported at this point). Also make sure that you have XCode installed and that you are attached to the Internet (the test suite will need Internet access to run a few tests).
Trinity:~ kelvin$ python -V
Python 2.5.2
Trinity:~ kelvin$ hg version
Mercurial Distributed SCM (version 1.0.1)
Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Trinity:~ kelvin$ xcodebuild -version
Xcode 3.1.2
Component versions: DevToolsCore-1148.0; DevToolsSupport-1102.0
BuildVersion: 9M2621
Trinity:~ kelvin$ uname -p
i386
Trinity:~ kelvin$
Okay, now we’re going to make some environment variables that Go will use to compile your code. In my home directory, I put the following variables into the ‘.bash_profile’ file:
# Google Go Lang Vars
export GOROOT=$HOME/go
export GOOS=darwin
export GOARCH=386
export GOBIN=$HOME/bin
export PATH=$GOBIN:$PATH
Now we make sure that the environment has the variables we just set up:
Trinity:~ kelvin$ source .bash_profile
Trinity:~ kelvin$ env | grep ^GO
GOBIN=/Users/kelvin/bin
GOARCH=386
GOROOT=/Users/kelvin/go
GOOS=darwin
Trinity:~ kelvin$
Make sure that your ‘~/go’ directory doesn’t exist since the next command will make it into a Mercurial repository. We will be creating the ‘~/bin’ directory after we create the repository.
Trinity:~ kelvin$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
requesting all changes
adding changesets
adding manifests
adding file changes
added 3976 changesets with 16799 changes to 2931 files
updating working directory
1640 files updated, 0 files merged, 0 files removed, 0 files unresolved
Trinity:~ kelvin$ cd $GOROOT
Trinity:go kelvin$ ls
AUTHORS LICENSE doc include misc src
CONTRIBUTORS README favicon.ico lib pkg test
Trinity:go kelvin$ cd src/
Trinity:src kelvin$
Okay, so far we have set-up the environment and the respository. Now would be a good time to ensure the ‘~/bin’ folder actually exists. In many cases, it is already there. If it isn’t there, you need to create it and mark it executable (Hint: Try ‘mkdir ~/bin’ then ‘chmod 755 ~/bin’). Make sure your spaces are in the next bit on code! One space of padding inside the square brackets!
Trinity:src kelvin$ [ -d ~/bin ] && echo 'bin exists'
bin exists
Trinity:src kelvin$
Okay, now we’re ready to build Go.
Trinity:src kelvin$ ./all.bash
rm -f *.o *.6 6.out lib9.a
rm -f bbuffered.o bfildes.o bflush.o bgetc.o bgetrune.o bgetd.o binit.o boffset.o bprint.o bputc.o bputrune.o brdline.o brdstr.o bread.o bseek.o bwrite.o *.6 6.out libbio.a
rm -f *.o *.so
.... holy crap there is a lot of output here...
./mkasmh.sh >386/asm.h.x
mv -f 386/asm.h.x 386/asm.h
8a 386/asm.s
8c -Idarwin -Idarwin/386 -wF cgocall.c
8c -Idarwin -Idarwin/386 -wF chan.c
8c -Idarwin -Idarwin/386 -wF 386/closure.c
8c -Idarwin -Idarwin/386 -wF float.c
8c -Idarwin -Idarwin/386 -wF hashmap.c
8c -Idarwin -Idarwin/386 -wF iface.c
quietgcc -o cgo2c cgo2c.c
./cgo2c malloc.cgo > malloc.c.tmp
mv -f malloc.c.tmp malloc.c
...Two peanuts were walking down the street. One was a salted...
8g -I_obj main.go
8l -L_obj -o ogle main.8
real 0m0.996s
user 0m0.831s
sys 0m0.148s
--- cd ../doc/progs
real 0m2.229s
user 0m1.714s
sys 0m0.431s
--- cd ../test/bench
fasta
reverse-complement
nbody
binary-tree
binary-tree-freelist
fannkuch
regex-dna
spectral-norm
k-nucleotide
mandelbrot
meteor-contest
pidigits
threadring
chameneosredux
--- cd ../test
0 known bugs; 0 unexpected bugs
Trinity:src kelvin$
Okay, so hopefully you now have a working copy of the Go programming language. You can try to find the executables on your system. Your compiler is ‘8g’ if for the i386 architecture.
Trinity:~ kelvin$ which 8g
/Users/kelvin/bin/8g
Trinity:~ kelvin$ which 8l
/Users/kelvin/bin/8l
Trinity:~ kelvin$ 8g
flags:
-I DIR search for packages in DIR
-d print declarations
-e no limit on number of errors printed
-f print stack frame structure
-h panic on an error
-k name specify package name
-o file specify output file
-S print the assembly language
-w print the parse tree after typing
-x print lex tokens
Trinity:~ kelvin$
Notice that ‘gccgo’ is not installed by default; if you want to try that out you need to install it separately. Try working through the examples!
