Thursday, November 12, 2009

There we Go.

Last week I visited Google for the first time. I even passed by Rob Pikes office...

Today I'm using the language he and his team just created. Lots of inspirations from C, python, limbo and friends, and I actually had fun playing around with it.

1 package main
2
3 import "fmt"
4
5 func PrintAll(x interface{}) {
6 var str string;
7 switch value := x.(type) {
8 case bool:
9 if value {
10 str = "True"
11 } else {
12 str = "False"
13 }
14 case string:
15 str = value
16 default:
17 return
18 }
19 fmt.Printf(str + "\n")
20 }
21
22
23 func main() {
24 PrintAll("Hello world");
25 PrintAll(true);
26 PrintAll(false);
27 }

Now look at that :-) Hello World, here we Go.
$ 6g test.go && 6l test.6 && ./6.out
Hello world
True
False

PS: "!" replaced with ".", emphasising that I'm talking about "Go" and not the "Go!" language.

27 comments:

robmv said...

ohhhh Uppercase method names... my eyes!!!!! :-)

sergk said...

D programming language version:

module main;

import std.stdio;

void PrintAll(T)(T x) {
string str;
static if (typeid (bool) is typeid (T)) {
if (x) {
str = "True";
} else {
str = "False";
}
}
else if (typeid (string) == typeid (typeof (x)))
str = x;
else
return;
std.stdio.writefln(str);
}

void main() {
PrintAll("Hello world");
PrintAll(true);
PrintAll(false);
}

sergk said...

Err... How to format code in comments?

Kenneth Rohde Christiansen said...

No idea how to format code in comments :-). Ah yeah, uppercase function names means that they are exported from the package, where as the lowercase named functions are not (thus private)

Calum said...

"By the time some newbie like Rob Pike comes up with an idea, it's already been in Haskell for years." -- Conrad Parker on #Go

self said...

I wonder what 'idea' Conrad was referring to. Quite a few ideas behind Go can be seen in Squeak/Newsqueak (not the Smalltalk Squeak), Alef, and Limbo -- all 15+ years old.

Anny said...

Look,Cheap GHD Straighteners,Discount GHD Styler,GHD Outlet,CHI hair Straighteners,2010 Cheap Sunglasses,Discount SunglassesSunglasses Outlet,wholesale Sunglasses,Sunglasses Wholesale. Do not worry. The urge to buy these goods will be very strong once you spot the shoes or clothes that you like. I am also a big fan for these products, although I like ED Hardy,cheap ED Hardy Clothes,discount ED Hardy Outlet,Wholesale Ed Hardy,Ed hardy wholesale, cheap Prada,discount Prada,Prada Outlet,newest Prada handbags,Prada handbags 2010, so I can understand. Online wholesale dealers have quite an array for you to choose from, including wholesale jewelry and handbags. And these are bags that bear the most famous names in the world of fashion, by the way -Prada, Spyder, Moncler, GHD, ED Hardy, designer Sunglasses, Ankh Royalty, Twisted Heart, or say AnkhRoyalty,Ankh Royalty,Ankh Royalty Clothing ,Ankh Royalty Clothes,AnkhRoyalty Outlet. Such variety that comes at incredibly affordable prices is a treat you can't possibly pass up on.

barazhao said...

jordan 8
There are cheap shoes to choose
jordan 9
You can have a look at it.
jordan 10
Funny things like this.
jordan 11
jordan 12
jordan 13

daiyanren said...

There are cheap shoes to choose
jordan 6
jordan 7
Good quality with low price.
air jordan 2010
Air Jordan 2009
You can have a look at it.
jordan shoes
jordan ajf shoes
We offer different styles.
jordan 1
jordan 2
If you like,you can contact us.
jordan 3
jordan 4
Thanks.
jordan 5
jumpmen23

barazhao said...

jordan 8
There are cheap shoes to choose
jordan 9
You can have a look at it.
jordan 10
Funny things like this.
jordan 11
jordan 12
jordan 13

小雨 said...

air jordans wholesale
wholesale nike shoes
wholesale nike sneakers

ally said...

Fashion is all about lookingmoncler jackets good and being comfortable at the same time. monclermoncler coatsEvery woman loves being complimentedmoncler t-shirtmoncler vestmoncler outlet for her sense of style and elegance. ugg bootscheap ugg bootsdiscount ugg bootsNo woman wants to be labeled as outdated and old fashioned.ugg classic tall bootsclassic ugg bootsWomen are expected to be in constant touch with the latest trends in ordermoncler jacketsmonclernew moncler coats to adopt those trends and look fashionable and stylish. moncler vestmoncler outletmoncler polo t-shirtWomen need to make sure that whatever they wear, coach outletcoach handbagscoach bagsit should compliment their personality and they do not feel awkward while wearing it. coach totescoach outletlouis vuitton handbagsAn article about Gothic costume clothing and the importance of choosing Gothic choker. LV handbags 2010Louis Vuitton bagsLouis Vuitton totesThis article explores the wide variety of Gothicrain boots
rainweardiesel jeans chokers available from everyday to special occasions. Ture Religion Jeanslevis jeansabercrombie and fitch outletIt should inspire people to go shopping for their own Gothic chokers. ed hardy wholesaleed hardy outletcheap ed hardy wholesaleThe origins of the Flat cap span discount ed hardy wholesalewholesale ed hardy

ally said...

Fashion trends change on daily basis, like Gold GHD. Following the latest in designer shades has become a passion of everyone, now Burberry Sunglasses. If you are the type of a woman who loves to explore in fashion, our ED Hardy Sunglasses will definitely satisfy your taste. Cheap Ed Hardy Sunglasses is also OK. Ed hardy streak of clothing is expanded into its wholesale ED Hardy T-shirt chain so that a large number of fans and users can enjoy the cheap ED Hardy Clothing range easily with the help of numerous secured websites, actually, our ED Hardy Outlet. As we all know, in fact discount ED Hardy, is based on the creations of the world renowned tattoo artist Don Ed Hardy. Well, this question is bound to strike the minds of all individuals. Many people may say Prada shoes is a joke, but we can give you Prada Sunglasses, because we have Prada handbags. Almost everyone will agree that Prada Purses are some of the most beautiful designer handbags marketed today. Now we have one new product: Prada totes. The reason is simple: fashion prohibited by ugg boots, in other words, we can say it as Cheap ugg boots. Would you like to wear Discount ugg boots. We have two kinds of fashionable boots: classic ugg boots and ugg classic tall boots. Ankh Royalty--the Cultural Revolution. Straightens out the collar, the epaulette epaulet, the Ankh Royalty Clothing two-row buckle. Now welcome to our Ankh Royalty Outlet. And these are different products that bear the most famous names in the world of fashion, like Ankh Royalty T shirt by the way -Prada, Spyder, Moncler(Moncler jackets,or you can say Moncler coats, Moncler T-shirt, Moncler vest,and you can buy them from our discount Moncler outlet), GHD, ED Hardy, Ankh Royalty, Twisted Heart.

militrade said...

you can't believe how worthy it is .
abercrombie

outlet

You can have a look at it.
abercrombie

fitch outlet

There are many kinds of name brand cheap jordan shoes to choose
nike outlet

hxl880 said...

tn requin

chaussures tn

chaussure requin


wall stickers

kids bedding

wedding jewelry

wedding cake

beaded lanyard

unlocked cell phones

handheld gps

travel guide

car seat cover

sexual health

wholesale lots


air max
air 90
air 95

samshen said...

www.monclerdesign.com
Moncler online
Moncler
Moncler Jackets
www.stylemoncler.com
moncler online shop
Moncler
Moncler Jackets
www.doudoune-moncler.net
Boutique en ligne Moncler
veste moncler
doudoune moncler

kiara said...

Costa Rica Tours
Tours Costa Rica

dfadf said...

Microsoft Office 2010
Office 2010
Office 2007
Microsoft Office
Microsoft Office 2007
Office 2007 key
Office 2007 download
Office 2007 Professional
Windows 7
Microsoft outlook 2010

Microsoft Office 2007 said...

NEVERTHELESS, THE CIVIL LAW is and must be neutral about who has a more noble or rewarding faith. The breakaway parishes ought to win every Office 2010facet of the lawsuit not becauseMicrosoft Office 2010 their beliefs or their politics are better, Microsoft wordbut because both lawOffice 2007and equity, along with common sense, are on Microsoft Officetheir side.Microsoft Office 2007 Not only does Virginia state law (the Division Statute)Office 2007 keyexplicitly apply to just such a Office 2007 downloadsituation as now exists, but the history Office 2007 Professionalespecially of The Falls Church argues against the claims of Outlook 2010the Virginia Diocese with which theyMicrosoft outlookhave disassociated.Microsoft outlook 2010First, The Falls Church wasWindows 7 founded, formed, and developed long before the diocese, or the national Episcopal Church, even existed.

weddingdresses said...

The Power Balance bracelet is made of pure surgical grade silicone that is extremely durable. Its stretch feature optimizes users' comfort level. It comes equipped with two, visible power balance holograms and this sporty and stylish bracelet goes with everything.

Specification:

Silicone Power Balance Wristband Bracelet
The band made of 100% silicone rubber
With 2 visible hologram disks for balance power,waterproof.

JUN said...

We hear of the mbt shoes clearance masque no more.Some time elapsed, after the death of our author, before any of his later productions appeared : two small editions of his minor pieces were at length sent to the press in 1640, coach bags outlet and in the subsequent year a wretched reprint of the first folio, and a second volume of the same km-, containing his dramatic pieces from 1612, several masques, and all that could be found of his occasional poetry, coach outlet coupon were published together. Several of the comedies appear to have been taken from the prompter's book, and surreptitiously printed (but not published) during the author's life; how the rest were procured I know not. cheap coach purses Such of his dramas as were revived at the Restoration were printed separately ; and in 1692 the whole of his writings were again collected, and published in one huge folio volume. The demand for his works must have been considerable for those days, since in mbt trainers 1716 the booksellers were encouraged to prepare another edition, which they gave the world in six volumes 8ro. This publication was merely a reprint of the old copy, and with this, defective as it was, the town was content till the year 1756, cheap coach bags when a more complete edition, in seven volumes, 8vo, was published by the Rev. Peter Whalley, LL. B.Mr. Whalley had received an academical education, and he was competent, in some measure, to the undertaking. He did little, however, for the poet ; the form of five finger shoes the old editions was rigidly observed, and though a few notes were subjoined, they were seldom of material import, and never explanatory of the author's general views, though they occasionally touched on his language. It is not a little remarkable that this gentleman, who was master of the Grammar School 5 finger shoes of Christ's Hospital, and must naturally have been somewhat conTenant with the ancient writers, should not have ventured on one remark of a literary nature, every thing of this kind, which occurs in his edition, being, coach outlet store online as I discovered with some surprise, taken from Upton and others.Whether Whalley was diffident of himself, or the gentlemen volunteered their assistance, I have no means of knowing ; but he availed himself occasionally of the aid coach purses outlet of Sympson and Scward, (the editors of Beaumont and Fletcher,) who led him astray, and where he would have been simply wrong, if left to himself, rendered him absurd. In one pleasant way of making notes, and swelling the bulk of the book, they all agreed.

JUN said...

We thought we had kept it long " enough, and by use of the flood water relieved ourselves from a considerable The North Face Sale quantity of stink by that means."Bishop Stortford has hitherto escaped litigation, but the same witness informed us,—" We have been threatened by several parties. Our neighbours at Sawbridgeworth have told us that we " have been poisoning them. We have said that we are sorry for it, but we think that they contribute to the " nuisance to some extent themselves, and we have Skechers Shoes therefore not heeded what they had to say."Millers on the same stream are almost obliged to resort to similar practices by way of self-defence. Mr. Garratt, of Hunsdon Mill, who has been much troubled with accumulation of mud, says,—" I find that other people send the mud to me ; and I had a Discount G Star Sale large hoe constructed, and I put four horses to " it, and I sent the mud down again into the navigation. It is cheaper than throwing it out."The condition of the lower end of the valley, where the population is much denser, and adoption of the watercloset system is more general, is of course much worse. Various towns on the Lee, and local authorities on the outskirts of London, have been or are at litigation one with another. To preserve the purity of Edmonton Brook, Edmonton has obtained an injunction against Enfield, and is applying for an injunction against North Face Outlet the Trustees of Colney Hatch Lunatic Asylum. Tottenham last year instituted proceedings against Hornsey for fouling Moselle Stream, but although both the fact of the nuisance and the right of Tottenham to relief were equally undoubted, no relief could be given by the law, because there was no public body at Hornsey to be made amenable. The Lee Trustees a few years ago obtained an injunction against the Metropolitan Board of Works, and 820/. damages in respect of injury done to the Shape Ups Shoes navigation by discharge of sewage from storm-water outlets belonging to the Board. The Lee. Trustees alsorecently filed a bill against the authorities of Tottenham, to put an end to the nuisance from their sewage works, and especially to prevent the sewage of WoodGreen and West-Green, which are Shape Ups Boots districts within Tottenham parish, being added to the sewage of the rest of the parish, which is now discharged into the Lee.

JUN said...

We thought we had kept it long " enough, and by use of the flood water relieved ourselves from a considerable The North Face Sale quantity of stink by that means."Bishop Stortford has hitherto escaped litigation, but the same witness informed us,—" We have been threatened by several parties. Our neighbours at Sawbridgeworth have told us that we " have been poisoning them. We have said that we are sorry for it, but we think that they contribute to the " nuisance to some extent themselves, and we have Skechers Shoes therefore not heeded what they had to say."Millers on the same stream are almost obliged to resort to similar practices by way of self-defence. Mr. Garratt, of Hunsdon Mill, who has been much troubled with accumulation of mud, says,—" I find that other people send the mud to me ; and I had a Discount G Star Sale large hoe constructed, and I put four horses to " it, and I sent the mud down again into the navigation. It is cheaper than throwing it out."The condition of the lower end of the valley, where the population is much denser, and adoption of the watercloset system is more general, is of course much worse. Various towns on the Lee, and local authorities on the outskirts of London, have been or are at litigation one with another. To preserve the purity of Edmonton Brook, Edmonton has obtained an injunction against Enfield, and is applying for an injunction against North Face Outlet the Trustees of Colney Hatch Lunatic Asylum. Tottenham last year instituted proceedings against Hornsey for fouling Moselle Stream, but although both the fact of the nuisance and the right of Tottenham to relief were equally undoubted, no relief could be given by the law, because there was no public body at Hornsey to be made amenable. The Lee Trustees a few years ago obtained an injunction against the Metropolitan Board of Works, and 820/. damages in respect of injury done to the Shape Ups Shoes navigation by discharge of sewage from storm-water outlets belonging to the Board. The Lee. Trustees alsorecently filed a bill against the authorities of Tottenham, to put an end to the nuisance from their sewage works, and especially to prevent the sewage of WoodGreen and West-Green, which are Shape Ups Boots districts within Tottenham parish, being added to the sewage of the rest of the parish, which is now discharged into the Lee.

Eshop said...

thanks for your sharing! great helpful!!!Thank you
Louboutin Shoes 
Christian Louboutin Shoes
Christian Louboutin Pumps 
louboutin
Christian Louboutin Boots 
Christian Louboutin Pumps
Christian Louboutin Heels 
Christian Louboutin Sandal
Pigalle Christian Louboutin 
fur boots
christian louboutin fur boots
louboutin pumps
louboutin fur boots
coyote fur boots
christian louboutin heels
silver strappy sandals
christian louboutin toundra
loubitan studded bow peep
Wedding Dress Shops
vintage wedding dresses 
wedding dresses
cheap mobile phone
Wedding Dress Shops
Wedding Dresses 2011
Wedding Dress Shops
Off the Shoulder Wedding Dresses
bridal jackets
wedding jackets
bridal jackets
halter neck wedding dresses
off the shoulder wedding dresses
vintage wedding dresses
wedding dresses with sleeves
wedding jackets for the bride

teralifeonline said...

Tera gold
Tera Item
Tera account

Runescape gold
buy Runescape gold

cheap wow gold
cheapest wow gold
lotro gold

Tera online
Tera gold
Tera items
Tera gold cheap
cheap Tera gold

Liz said...

3
江詩丹頓
隔熱紙
樟芝
白蟻
跳蚤
香港平價住宿
民宿
裝潢
外籍新娘
男性結紮

Jordans Nike said...

cheap nike jordan shoes, wholesale jordan shoes, ugg boots, ugg, air jordan shoes, cheap nike shoes, cheap nike air max, Cheap jordans, cheap jordan shoes, Cheap Louis Vuitton Handbags, discount nike jordans, cheap jordans, wholesale jordan shoes, cheap nike free, Cheap LV Handbags, nike free, cheap nike free run, jordan shoes for cheap, ugg pas cher, cheap jordan, Bags Louis Vuitton, uggs outlet, ugg australia, ugg soldes, Discount LV Handbags, Cheap Nike jordan shoes, uggs on sale, cheap jordans, wholesale jordan shoes for sale, Discount Louis Vuitton