wangwang / go-tour Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/go-tour
License: BSD 3-Clause "New" or "Revised" License
Automatically exported from code.google.com/p/go-tour
License: BSD 3-Clause "New" or "Revised" License
The syntax highlighting scheme does not match Go's syntax.
It highlights non-reserved words. For example, looking at the front page right
now 'string' appears in the same color as 'func' and 'return', suggesting that
it is a reserved word too. But it is not. Variables and fields called string
are just fine and should not be highlighted.
Original issue reported on code.google.com by [email protected]
on 13 Sep 2012 at 10:48
On my machine (MacOS X) running the go tour locally, on slide 69 we are
suggested to generate a "random" binary tree using tree.New(k).
However this always produce the same binary tree, since the rng is not seeded.
a way to solve this would be to do as follows:
rand.Seed(time.Now().UnixNano())
from the code itself, but maybe best would be to have it added in the New()
function:
$ hg diff
diff -r ca1c030f0dfb tree/tree.go
--- a/tree/tree.go Wed May 23 15:11:31 2012 +1000
+++ b/tree/tree.go Wed May 30 22:03:45 2012 +0200
@@ -7,6 +7,7 @@
import (
"fmt"
"math/rand"
+ "time"
)
// A Tree is a binary tree with integer values.
@@ -19,6 +20,7 @@
// New returns a new, random binary tree holding the values k, 2k, ..., 10k.
func New(k int) *Tree {
var t *Tree
+ rand.Seed(time.Now().UnixNano())
for _, v := range rand.Perm(10) {
t = insert(t, (1+v)*k)
}
Not sure if this would be idiomatic though
Alternatively, it could be added as a comment in the code part of the slice, so
that we can show the difference ...
Alain
Original issue reported on code.google.com by [email protected]
on 30 May 2012 at 8:05
Enable code review to allow contributions.
Original issue reported on code.google.com by [email protected]
on 4 Oct 2011 at 5:52
To mapping to C/C++ INT_MAX,INT_MIN,
I think use signed int64 is better than uint64
MaxInt int64 = 1<<63 - 1
MinInt int64 = -(1<<63)
What version of the product are you using? On what operating system?
1ee650a26106
Please provide any additional information below.
Here is my modified sample.
package main
import (
"math/cmplx"
"fmt"
)
var (
ToBe bool = false
MaxInt int64 = 1<<63 - 1
MinInt int64 = -(1<<63)
z complex128 = cmplx.Sqrt(-5+12i)
)
func main() {
const f = "%T(%v)\n"
fmt.Printf(f, ToBe, ToBe)
fmt.Printf(f, MaxInt, MaxInt)
fmt.Printf(f, MaxInt, MaxInt+1)
fmt.Printf(f, MinInt, MinInt)
fmt.Printf(f, MinInt, MinInt-1)
fmt.Printf(f, z, z)
}
Original issue reported on code.google.com by [email protected]
on 28 Feb 2012 at 1:05
>What steps will reproduce the problem?
1. Start go-tour in a tabbed browser with at least one other tab open
2. Press Ctrl+page up to switch to a different tab
3. Press Ctrl+page down to switch back
>What is the expected output? What do you see instead?
Expect to stay on same slide in go-tour; instead, go-tour progresses to next
slide when I return to the tab.
>What version of the product are you using? On what operating system?
Unknown; gotour does not respond to --version. I installed it earlier today
with `go get code.google.com/p/go-tour/gotour`
>Please provide any additional information below.
Replicated in Firefox 12.0 on Ubuntu 12.04. Curiously, does not happen on
Chromium 18.0.1025.151 Ubuntu 12.04.
I believe the patch below may address it, but I don't see build or test
instructions anywhere obvious, and as a go novice, I can't invest the time to
figure this out right now.
Come to think of it, it's somewhat dubious of Firefox to send these events to
the page at all, but working around the issue would make for a better go user
experience.
Original issue reported on code.google.com by [email protected]
on 10 Jun 2012 at 2:16
Attachments:
What steps will reproduce the problem?
1. go to http://tour.golang.org/#56
2. The text says "In this example, the type MyHandler implements http.Handler."
3. 'MyHandler' is nowhere to be seen in the code sample
What is the expected output? What do you see instead?
Should the above code snippet say 'MyHandler' instead of 'Handler'?
Original issue reported on code.google.com by [email protected]
on 3 Jan 2012 at 4:30
Here is my example, I think 4 steps Insert/Update/Delete/Query are very
important.
var m = map[string]int{ "Mon":1, "Tue":2 }
for k,v := range m { fmt.Println("k=",k,"v=",v"} // display
// NOTE: iterate order is dynamic, don't treat it is consistent
m["Wed"] = 2 // insert
m["Wed"] = 3 // update
delete(m,"Wed") // delete
var m2 = make(map[string]string, 1e4) // pre-allocate initial size
What version of the product are you using? On what operating system?
1ee650a26106
Original issue reported on code.google.com by [email protected]
on 28 Feb 2012 at 1:16
There are some import "code.google.com/gotour/*" in the html file. When someone
fork the project, he need to replace them. Also there no i18n support.
Original issue reported on code.google.com by [email protected]
on 31 May 2012 at 10:32
What steps will reproduce the problem?
1. Run go get code.google.com/p/go-tour/... as advertised on the home page
$ go get code.google.com/p/go-tour/...
package appengine: unrecognized import path "appengine"
package appengine/urlfetch: unrecognized import path "appengine/urlfetch"
What is the expected output? What do you see instead?
No output, gotour binary available in $GOPATH/bin.
What version of the product are you using? On what operating system?
go version go1.0.2
I installed go through "homebrew" for the Mac, my GOPATH is
/usr/local/Cellar/go/1.0.2/.
Original issue reported on code.google.com by [email protected]
on 22 Sep 2012 at 12:31
There is no method receiver v. The p is more suitable for this description, is
not that right?
Original issue reported on code.google.com by [email protected]
on 12 Oct 2011 at 6:11
Attachments:
What steps will reproduce the problem?
1. Run gotour
2. Run examples in browser
3. No output is visible
I use win7 and tryed in Chrome and Firefox, same result in both - no output.
Original issue reported on code.google.com by [email protected]
on 12 Apr 2012 at 8:27
The tour should briefly discuss memory management and garbage collection.
Original issue reported on code.google.com by [email protected]
on 4 Oct 2011 at 5:51
It doesn't reduce the depth when calling crawl recursively, so the the depth is
ineffective currently.
Original issue reported on code.google.com by joelai85
on 26 Oct 2012 at 6:18
What steps will reproduce the problem?
1. run the gotour and look at the slide 43 "Exercise: Loops and Functions"
What is the expected output? What do you see instead?
The hint is misleading. Looking at the provided Newton formula, there is z in denominator. The hint suggest using z := 0.0 as a starting point. This directly leads to division by zero.
It'l be better to use another value for the hint. For instance 1.0. or x/2.
What version of the product are you using? On what operating system?
I think the last from repository. I checked it out yesterday.
Please provide any additional information below.
Original issue reported on code.google.com by Radek.Hnilica
on 22 Oct 2011 at 2:15
Explain the mystifying nature of time in the sandbox
Probably remove the select example that relies on time, or find some way to
make it work.
Original issue reported on code.google.com by [email protected]
on 2 Dec 2011 at 2:04
What steps will reproduce the problem?
1. type `go get code.google.com/p/go-tour/gotour`
2.
3.
What is the expected output? What do you see instead?
Nothing happens. I'd expect to build and subsequently be able to run the gotour
executable.
What version of the product are you using? On what operating system?
$ go version
go version go1.0.2
installed via homebrew on mac os x lion
Please provide any additional information below.
I also tried setting the GOPATH, which didn't seem to change anything.
$ mkdir ~/.golib
$ GOPATH=~/.golib
$ export GOPATH
$ echo $GOPATH
/Users/gerad/.golib
$ go get code.google.com/p/go-tour/gotour
$
Original issue reported on code.google.com by [email protected]
on 13 Jul 2012 at 1:39
What steps will reproduce the problem?
1. use latest go weekly
2. try to goinstall
3. source code not up to date, gofix can't fix all issues
What is the expected output? What do you see instead?
good: should work
bad: this error after running gofix on all *.go files left:
goinstall go-tour.googlecode.com/hg/gotour
/bin/bash: === cd /home/aj/go/src/pkg/go-tour.googlecode.com/hg/gotour; bash
gomake -f- install
6g -I "/home/aj/go/pkg/linux_amd64" -I "/home/aj/go/pkg/linux_amd64" -o
_go_.6 goplay.go local.go
goplay.go:29: err.String undefined (type error has no field or method String)
make: *** [_go_.6] Fehler 1
--- exit status 2
What version of the product are you using? On what operating system?
go weekly latest release on linux amd64.
Please provide any additional information below.
My workaround is to comment out that line
// resp.Errors = err.String()
but that is obviously not the right result. what is the proper fix?
Andreas
Original issue reported on code.google.com by [email protected]
on 13 Nov 2011 at 7:39
There is no MyHandler. So, I changed the type, MyHandler instead of Hello.
I'd like to review this change.
Original issue reported on code.google.com by [email protected]
on 12 Oct 2011 at 7:23
Attachments:
The tour should briefly talk about scope.
Original issue reported on code.google.com by [email protected]
on 4 Oct 2011 at 5:51
What steps will reproduce the problem?
1. http://tour.golang.org/#47
What version of the product are you using? On what operating system?
1ee650a26106
Please provide any additional information below.
It should be
http://weekly.golang.org/pkg/math/cmplx/
Original issue reported on code.google.com by [email protected]
on 28 Feb 2012 at 2:46
What steps will reproduce the problem?
1. Install .msi installer
2. Run go tour
3. Click "Run", see nothing.
What version of the product are you using? On what operating system?
Go.1 on Windows 7 32-bit installed with the .msi installer.
Original issue reported on code.google.com by [email protected]
on 16 Apr 2012 at 11:49
Allow me to apologize ahead of time as this is most likely not the correct
place to post this information, but I think it may help some people who I've
noticed may be having the same problem as I did. This is how I (finally) go the
tour to start. Not sure if it was how I installed go, the tour, or my system or
path settings, etc. or if maybe the code that is supposed to run the gotour
when you enter the command sudo go run gotour has something wrong with it.
Check me on all this if you wish. Anyway, here goes . . .
What steps will reproduce the problem?
1. sudo apt-get install golang
2. go get code.google.com/p/go-tour/gotour
3. sudo go run gotour
What is the expected output? What do you see instead?
I'm probably way off base here but following those instructions I personally
would have expected go to run the gotour that go had just went and got in step
2, i.e. go get code.google.com/p/go-tour/gotour.
What actually happened was I got an error that no go files were found. Here's
how I fixed it . . .
1. cd to your /home/<user>/gocode/pkg directory. If it is not there use sudo
mkdir to make the directory pkg in /home/<user>/gocode/.
2. go get the gotour code from code.google.com and make sure it gets put into
the following directory . . . /home/<user>/gocode/pkg/
NOTE: you may have to look around and find where mercurial put the code.google.com stuff and the sudo cp -R code.google.com /home/<user>/gocode/pkg/ (This should recursively copy the code.google.com directory tree you just got with mercurial into a directory where we can get something going right :) Of course, be sure to chmod -R the code.google.com that you just copied into /home/<user>/gocode/pkg/ such that it will not require a sudo command each time you want to use it. If you are using something like Ubuntu on your own personal computer, you are the only user, and your dont expect anyone would be able to get into your system and do anything naughty to your code.google.com directory then the command would be sudo chmod a+wrx -R code.google.com
. . . moving on
3. in terminal type go run
/home/<user>/gocode/pkg/code.google.com/p/go-tour/gotour/local.go
terminal wil output the following
<date> <time> Serving content from /usr/lib/go/src/pkg/code.google.com/p/go-tour
<date> <time> Open your web browser and visit http://127.0.0.1:3999/
4. right click this link and copy it, then paste it into the address bar of
your web browser and your all set.
Like I said earlier, I know this is probably a
round-about-way-of-doing-something but nobody else's answers were helping and
this is the only way I could figure it to work for me. Keep in mind it is 6:09
am and I have been awake for nearly 24 hours by now lol. Anyway, hope it helps
and makes sense to anyone who needs the help. I'm off the gotour and start
playing with go :)
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 29 Oct 2012 at 10:11
Add a slide to discuss slices/maps/functions as reference values.
Original issue reported on code.google.com by [email protected]
on 4 Oct 2011 at 6:24
Key issues:
- The arrows shouldn't be only at the bottom of the screen. They should be
located near the other controls. They are not very discoverable. I would expect
the forward/back/toc/page# elements to be colocated.
- The table of contents icon can be confusing. It looks like a forward/backward
control, but it's not.
Original issue reported on code.google.com by [email protected]
on 14 Sep 2012 at 3:55
I flailed a bit when trying to implement and test complex
cube root (exercise on page 46) because I was trying to:
import "cmplx"
This failed with:
# command-line-arguments
.\cbrt.go:13: imported and not used: "cmplx"
.\cbrt.go:25: undefined: cmplx
Because the correct path is "math/cmplx", which it
took me 10 minutes to figure out. Perhaps the hint about
cmplx.Pow could mention the path for the package.
Original issue reported on code.google.com by [email protected]
on 1 Apr 2012 at 12:48
Let's find out which code samples people are running, which slides people are
viewing, etc.
Original issue reported on code.google.com by [email protected]
on 5 Oct 2011 at 6:21
In the current repository, gotour/solutions/slices.go of revision
"afef612d0519" is like (line 15 ~ 19):
for y := range p {
for x, row := range p[y] {
row[x] = uint8(x * y)
}
}
But it should be:
for y := range p {
row := p[y]
for x := range row {
row[x] = uint8(x * y)
}
}
Original issue reported on code.google.com by [email protected]
on 23 Nov 2012 at 6:41
What steps will reproduce the problem?
1. Follow the instructions for "Exercise: Slices", creating pic.go
(see example below).
2. Run the program (go run pic.go)
What is the expected output? What do you see instead?
I expected to see an image displayed on screen.
The exercise says:
When you run the program, it will display
your picture, interpreting the integers as
grayscale (well, bluescale) values.
Instead, the console was filled with what appeared
to be an ascii encoding of an image:
IMAGE:iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAI...
I examined the downloaded code, and sure enough,
it just emits such text. Is there no way (yet)
to at least display an image (if not a full UI)?
What version of the product are you using? On what operating system?
go 1 (64-bit).
tour downloaded on 2012/03/31.
Windows 7, 64-bit.
Please provide any additional information below.
Here is the code I tested with:
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
img := make([][]uint8, dy)
for y := range img {
img[y] = make([]uint8, dx)
for x := range img[y] {
img[y][x] = uint8(x * y)
}
}
return img
}
func main() {
pic.Show(Pic)
}
Original issue reported on code.google.com by [email protected]
on 7 Apr 2012 at 2:14
The text on the Web servers slide (slide 56) refers to a type called MyHandler
in the code. However, the type in the code is named Hello. This change fixes
the slide text to refer to type Hello instead of MyHandler.
Original issue reported on code.google.com by [email protected]
on 11 Dec 2011 at 7:50
Attachments:
What steps will reproduce the problem?
1. Visit http://code.google.com/p/go-tour/
2. Click 'go' link in the text 'First install Go and then use go to install
gotour'
What is the expected output? What do you see instead?
Expect information about the utility named 'go', instead I see:
"File go
file not found: /tmp/adg/godoc/go-doc/src/cmd/go"
What version of the product are you using? On what operating system?
N/A
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 5 Mar 2012 at 3:21
Running on Windows 7 64bit
Installed Go
Installed Mercurial
Ran the following:
> go get code.google.com/p/go-tour/gotour
No output of bugs... installation ok(?)
Ran
> gotour
output:
2012/03/28 22:10:29 Serving content from C:\Go\src\pkg\code.google.com\p\go-tour
2012/03/28 22:10:29 Serving at http://127.0.0.1:3999/
... then it hangs there. Nothing happens.
Any suggestions?
Original issue reported on code.google.com by [email protected]
on 29 Mar 2012 at 2:16
An oft-requested feature.
Two viable drop-in tools:
http://codemirror.net/
http://ace.ajax.org/
Original issue reported on code.google.com by [email protected]
on 4 Oct 2011 at 5:50
What steps will reproduce the problem?
1. http://tour.golang.org/#37
What version of the product are you using? On what operating system?
1ee650a26106
Please provide any additional information below.
In your slide, it is better to speak out, 'sum' variable is like static
variable in C/C++.
Here is my example.
// use closure method to implement static variable
func f() func() int {
i := 100
return func() int { i++ ; return i }
}
func main() {
next := f()
println(next(), next(), next())
}
Original issue reported on code.google.com by [email protected]
on 28 Feb 2012 at 1:20
The new editor did away with the Kill button. We need to re-implement it.
Original issue reported on code.google.com by [email protected]
on 12 Oct 2011 at 11:11
What steps will reproduce the problem?
1. Try to install it ("")
2.
3.
What is the expected output? What do you see instead?
The expected output is a successful installation (not sure of how it would look
like). The actual output is:
diogo@diogo-arch-desktop-home:~$ goinstall go-tour.googlecode.com/hg/gotour
/bin/bash: === cd /home/diogo/gocode/src/go-tour.googlecode.com/hg/pic; bash
gomake -f- install
6g -I "/opt/go/pkg/linux_amd64" -I "/home/diogo/gocode/pkg/linux_amd64" -p
go-tour.googlecode.com/hg/pic -o _go_.6 pic.go
pic.go:21: cannot use dx (type int) as type image.Rectangle in function argument
pic.go:21: too many arguments in call to image.NewNRGBA
make: ** [_go_.6] Erro 1
--- exit status 2
goinstall: go-tour.googlecode.com/hg/pic: install: running bash: exit status 2
What version of the product are you using? On what operating system?
ArchLinux 64-bits / 6g version weekly.2011-09-21 9913
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 6 Oct 2011 at 5:42
What steps will reproduce the problem?
1. get latest weekly go source
2. go get install -a code.google.com/p/go-tour/gotour
What is the expected output? What do you see instead?
# code.google.com/p/go-tour/gotour
go/src/pkg/code.google.com/p/go-tour/gotour/local.go:64: undefined:
build.FindTree
What version of the product are you using? On what operating system?
weekly
Please provide any additional information below.
I suspect this has something to do with the new redesign of the go/build package
http://code.google.com/p/go/source/detail?r=f4470a54e6dbcdd52d8d404e12e4754adcd2
c948&name=weekly
Original issue reported on code.google.com by [email protected]
on 5 Mar 2012 at 6:27
installing the go-tour package produces a compiler error in pic.go
What steps will reproduce the problem?
$ goinstall go-tour.googlecode.com/hg/gotour
/bin/bash: === cd /home/krs/go/src/pkg/go-tour.googlecode.com/hg/pic; bash
gomake -f- install
6g -I "/home/krs/go/pkg/linux_amd64" -I "/home/krs/go/bin/pkg/linux_amd64" -p
go-tour.googlecode.com/hg/pic -o _go_.6 pic.go
pic.go:21: cannot use dx (type int) as type image.Rectangle in function argument
pic.go:21: too many arguments in call to image.NewNRGBA
make: *** [_go_.6] Error 1
--- exit status 2
goinstall: go-tour.googlecode.com/hg/pic: install: running bash: exit status 2
What version of the product are you using? On what operating system?
$ 6g -V
6g version weekly.2011-09-21 9927
$ uname -a
Linux miranda 3.0.0-4.dmz.2-liquorix-amd64 #1 ZEN SMP PREEMPT Tue Sep 6
01:59:23 CDT 2011 x86_64 GNU/Linux
Original issue reported on code.google.com by [email protected]
on 5 Oct 2011 at 1:03
What steps will reproduce the problem?
1. Running go get code.google.com/p/go-tour/gotour does nothing
No executable is downloaded, no error messages are displayed.
>>What is the expected output?
An executable should be downloaded
>>What do you see instead?
Absolutely nothing
>>What version of the product are you using?
go1.0.3
>>On what operating system?
XP 32 bit, SP3
Original issue reported on code.google.com by [email protected]
on 13 Nov 2012 at 12:45
What steps will reproduce the problem?
1. Go to http://tour.golang.org/#42
2. Click Run
3. Add fmt.Println(today)
4. Click Run
So, it is Saturday now, but server says that Saturday is "too far away" and
after step 3-4 says Tuesday now. Is server locates in Narnia?
Mozilla Iceweasel 10.0.5, on-line version of go-tour.
Original issue reported on code.google.com by [email protected]
on 16 Jun 2012 at 3:40
Allow people to close the Go Tour tab and automatically go back to where they
were when they return.
Original issue reported on code.google.com by [email protected]
on 22 Oct 2011 at 2:38
What steps will reproduce the problem?
1.go get code.google.com/p/go-tour/gotour
2.
3.
What is the expected output? What do you see instead?
no idea what i should see. what i saw instead was "package
code.google.com/p/go-tour/gotour: mkdir /usr/local/go/src/pkg/code.google.com:
permission denied"
What version of the product are you using? On what operating system?
what version? i dunno, today's? Mac OS X Lion
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 24 May 2012 at 11:08
The Documentation page at http://golang.org/doc/ should have another section
for the large number of Ubuntu Linux users wanting a one-step installation
option using apt-get command on the Terminal:
sudo apt-get install golang-go
Currently it is missing.
The aforementioned command has been tested on the Ubuntu version 12.04 (Precise
Pangolin) LTS
Original issue reported on code.google.com by [email protected]
on 28 Oct 2012 at 11:40
What steps will reproduce the problem?
1. Enter the command: go get code.google.com/p/go-tour/gotour
2.
3.
What is the expected output? What do you see instead?
I expect it to install, but instead I get this error:
package code.google.com/p/go-tour/gotour: mkdir
/usr/lib/google-golang/src/pkg/code.google.com: permission denied
What version of the product are you using? On what operating system?
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
GOOGLE_CODENAME=precise
GOOGLE_ID=Goobuntu
GOOGLE_RELEASE="12.04 201209PD2-3"
GOOGLE_ROLE=desktop
GOOGLE_TRACK=stable
Please provide any additional information below.
I'm not sure why it wouldn't have permission. Sudo doesn't work either.
Original issue reported on code.google.com by [email protected]
on 5 Oct 2012 at 12:59
When I did finally get the gotour to work locally, running the program just
gave me this error. Again, probably something wrong on my end. If so, maybe
someone can offer some pointers as to exactly what is wrong because I'm lost
for now.
Original issue reported on code.google.com by [email protected]
on 29 Oct 2012 at 10:19
When a user has messed up their code sample, it would be nice to have a means
of restoring it to its original state.
Original issue reported on code.google.com by [email protected]
on 4 Oct 2011 at 5:50
What steps will reproduce the problem?
1. goinstall go-tour.googlecode.com/hg/gotour
2. compile failed.
What do you see instead?
6g -I "/opt/go/pkg/linux_amd64" -I "/opt/go/pkg/linux_amd64" -p
go-tour.googlecode.com/hg/pic -o _go_.6 pic.go
pic.go:21: cannot use dx (type int) as type image.Rectangle in function argument
pic.go:21: too many arguments in call to image.NewNRGBA
make: *** [_go_.6] Error 1
--- exit status 2
goinstall: go-tour.googlecode.com/hg/pic: install: running bash: exit status 2
What version of the product are you using? On what operating system?
go from hg on archlinux
Original issue reported on code.google.com by [email protected]
on 5 Oct 2011 at 8:07
I've seen the main page and the content in go.
We could run on r60.3.
But, it shows r60.1
Original issue reported on code.google.com by [email protected]
on 26 Oct 2011 at 1:44
It should be very useful to be able to specify a custom index.html
something like :
$ gotour -slides=/opt/my-go-talk/custom_slides.html
It would allow users to easily customize the slides (and probably translate
them into their audience's language) and use gotour as a powerful tool to
present Go to beginners.
Original issue reported on code.google.com by [email protected]
on 6 Oct 2011 at 8:46
Discovered this whilst browsing the Go Tour on my iPad, when new pages of the
tour are display (pressing previous/next) the software keyboard is displayed
every time. I am unsure whether this is the intended behavior of the Go Tour,
but regardless, it was very frustrating on a mobile device.
This is being caused by line 185 of /static/tour.js
(https://code.google.com/p/go-tour/source/browse/static/tour.js#185):
181 } else {
182 $('#workspace').show();
183 $output.empty();
184 editor.setValue(load(i) || $s.find('pre.source').text());
185 editor.focus();
186 }
I propose that setting focus of the code area should only happen when the
client is known to have a hardware keyboard. This may be a rather big ask, so
instead, don't set focus on a mobile device.
Original issue reported on code.google.com by [email protected]
on 16 Sep 2012 at 7:57
not all these need to be in the tour, and many are in effective go, but for the
record:
- runes and rune constants
- constant promotion
- the blank identifier
- the zero value
- initialization of local variables
- taking the address of a local variable
- init() functions
- defer
- panic and recover
- multi-file packages
- universe, package, file scope
- compilation
- godoc
- gofmt
- arrays
- pointer vs. value receiver
- resizing, reslicing, append, and copy
- embedding interfaces
- embedding structs
- type assertions
- interface-to-value, value-to-interface, interface-to-interface assignment
- type switch
- reflection
- segmented stacks
- the function-returning-channel idiom
- typed directional channels
some examples from the go course:
===
random bit generator
c := make(chan int)
go func() {
for {
fmt.Println(<-c)
} }()
for { select {
case c <- 0: // no statement, no fall through
case c <- 1:
}
}
===
timeout
select {
case v := <-ch:
fmt.Println("received", v)
case <-time.After(30*1e9):
fmt.Println("timed out after 30 seconds")
}
===
muxing server (in the tutorial)
type request struct { a,b int
replyc chan int
}
type binOp func(a, b int) int
func run(op binOp, req *request) {
req.replyc <- op(req.a, req.b)
}
func server(op binOp, service <-chan *request) {
for {
req := <-service // requests arrive here
go run(op, req) // don't wait for op
}
}
func startServer(op binOp) chan<- *request {
service := make(chan *request)
go server(op, req)
return service
}
adderChan := startServer(
func(a, b int) int { return a + b }
)
func (r *request) String() string {
return fmt.Sprintf("%d+%d=%d",
r.a, r.b, <-r.replyc)
}
req1 := &request{7, 8, make(chan int)}
req2 := &request{17, 18, make(chan int)}
adderChan <- req1
adderChan <- req2
Can retrieve results in any order; r.replyc demuxes:
fmt.Println(req2, req1)
===
chaining
package main
import ("flag"; "fmt")
var nGoroutine = flag.Int("n", 100000, "how many")
func f(left, right chan int) { left <- 1 + <-right }
func main() {
flag.Parse()
leftmost := make(chan int)
var left, right chan int = nil, leftmost
for i := 0; i < *nGoroutine; i++ {
left, right = right, make(chan int)
go f(left, right) }
right <- 0 // bang!
x := <-leftmost // wait for completion
fmt.Println(x) // 100000
}
===
channel as buffer cache
var freeList = make(chan *Buffer, 100)
var serverChan = make(chan *Buffer)
func server() {
for {
b := <-serverChan // Wait for work to do.
process(b) // Process the request in buffer.
select {
case freeList <- b: // Reuse buffer if room.
default:
} }}
func client() {
for {
// Otherwise drop it.
var b *Buffer
select {
case b = <-freeList:
default: b = new(Buffer) // Allocate if not.
}
load(b) // Read next request into b.
serverChan <- b // Send request to server.
// Grab one if available.
} }
====
also: the fan-out database example
Original issue reported on code.google.com by [email protected]
on 18 Dec 2011 at 5:13
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.