The actual web pages for “A Tour of Go” moved to golang.org/x/website.
This repo still holds the supporting packages like golang.org/x/tour/pic.
[mirror] A Tour of Go
License: BSD 3-Clause "New" or "Revised" License
The actual web pages for “A Tour of Go” moved to golang.org/x/website.
This repo still holds the supporting packages like golang.org/x/tour/pic.
Context: https://tour.golang.org/basics/3
In the instructions it states that
Run the code. Notice the error message.
To fix the error, rename math.pi to math.Pi and try it again.
But the code sample provided is already using math.Pi
, so the code compiles without errors.
https://go-tour-es.appspot.com/#46
Has some things in "nota" written in portugues
Context: https://tour.golang.org/welcome/2
In other language's this page,needs a link to English tour,it would make man find English pages easy.
Change the title above to describe your issue and add your feedback here, including code if necessary
Hello expert:
When go through the golang tour, I encounter an issue that confused me, could you please help to explain?
The scenarios could be: I have a original array (names), and copy partial data to slice (a), then I add additional data to slice (a), then the original array is affected. Please note that I use additional value to append to splice, I wonder why the original array are affected, many thanks for your answer!
Best Regards
Chengchang
Context: https://tour.golang.org/moretypes/8
package main
import "fmt"
func main() {
names := [4]string{
"John",
"Paul",
"George",
"Ringo",
}
fmt.Println(names)
a := names[0:3]
fmt.Println(a)
add := "xxxx"
a = append(a, add)
fmt.Println(a)
fmt.Println(names)
}
Context: https://tour.golang.org/concurrency/5
It took me a bit of time to understand what was going on on this step.
Until I realized that the go func() was actually waiting for the Fibonacci sequence function to send information to the channel, and was also stopping it by sending something into quit.
I simply added some print to figure this out, but I guess it might be worth improving the description or code snippet.
Context: https://tour.golang.org/welcome/1
Change the title above to describe your issue and add your feedback here, including code if necessary
I followed the instructions in Go Offline
(https://tour.golang.org/welcome/3) and ran the tour tool with go tool tour
. On the lesson Exercise: Slices
, when I provide the following code, only about 30% of the image renders.
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
var img [][]uint8
img = make([][]uint8, dy)
for y := range img {
img[y] = make([]uint8, dx)
for x := range img[y] {
img[y][x] = uint8(((x*x)^(y*y))/2)
}
}
return img
}
func main() {
pic.Show(Pic)
}
The image is followed by a really long string (46,138 characters!).
It seems like this might be related to how long it takes to render the image. If I change the line img[y][x] = uint8(((x*x)^(y*y))/2)
to img[y][x] = uint8(((x*x)^(y*y)))
, for example, sometimes about 75% of the image renders, and sometimes 100% of the image renders. When the entire image renders, the long string does not appear. In both cases Program exited.
is printed at the very bottom.
If I change the pixel equation to img[y][x] = uint8(x^y)
, it seems to always finish rendering.
This problem does not occur in the online tour (https://tour.golang.org/moretypes/18); just the offline one running on my workstation.
Context: https://go-tour-jp.appspot.com/list
Change the title above to describe your issue and add your feedback here, including code if necessary
Context: https://tour.golang.org/basics/1
I wanted to get a different number each time from this example, so I took the suggestion to seed the number generator.
Here is my code:
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UTC().UnixNano())
fmt.Println("My favorite number is", rand.Intn(9001))
}
When I execute the above code in the tour, the same number is returned every time as if seeding the number generator has no effect.
When I execute this code locally (go version go1.6.2 darwin/amd64) it returns a different number each time as expected.
Context: https://tour.golang.org/flowcontrol/3
The tour doesn't display results on Run button click, just 'Program exited.'.
Browsers: Chrome, Firefox
OS: Ubuntu
Please investigate. Thanks.
Context: https://tour.golang.org/flowcontrol/7
In the narrative on the left of step 7, the reference to main
is not rendered correctly, no doubt due to the quote character that follows in the text - it's rendered as main
and not main
.
Context: https://tour.golang.org/moretypes/18
In the exercises it may be helpful to see the code implementation or some other helpful tips to write code.
Context: http://127.0.0.1:3999/moretypes/10
given s := []int{2, 3, 5, 7, 11, 13}
, s[1:4]
gives [3 5 7]
. This is correct. However, s[:4]
gives [3 5 7 11]
this is clearly incorrect. Here is the complete code:
package main
import "fmt"
func main() {
s := []int{2, 3, 5, 7, 11, 13}
s = s[1:4]
fmt.Println(s)
s = s[:4]
fmt.Println(s)
}
and the output:
[3 5 7]
[3 5 7 11]
Program exited.
The same behavior is present at https://tour.golang.org/moretypes/10
Context: https://tour.golang.org/methods/23
I've solved methods/23 like this:
func (old_reader rot13Reader) Read(b []byte) (int, error) {
const LEN int = 1024
tmp_bytes := make([]byte, LEN)
old_len, err := old_reader.r.Read(tmp_bytes)
if err == nil {
tmp_bytes = tmp_bytes[:old_len]
rot13(tmp_bytes)
return len(tmp_bytes), nil
} else {
return 0, err
}
}
func main() {
s := strings.NewReader("Lbh penpxrq gur pbqr!")
r := rot13Reader{s}
io.Copy(os.Stdout, &r)
}
where rot13
is correct, but I can't see any output, process just exits. Debug output just before return len(tmp_bytes), nil
shows correct string.
Context: https://tour.golang.org/concurrency/9
I removed the Lock
and Unlock
from both the Inc
and Value
methods and still keep getting 1000. I suspect that this may be some caching thing, or perhaps the program is only single threaded. Either way, it doesn't really drive home the importance of synchronization...
Context: https://tour.golang.org/moretypes/23
I am getting below error messages but not sure what went wrong:
FAIL
f("I am learning Go!") =
map[string]int{"I":1, "am":1, "learning":1, "GO":1}
want:
map[string]int{"I":1, "am":1, "learning":1, "Go!":1}
Program exited.
Context: https://tour.golang.org/moretypes/21
Change the title above to describe your issue and add your feedback here, including code if necessary
Hi, why does the output of the map-literals-continued.go show "Google" is the first element, and "Bell Labs" the second?
map[Google:{37.42202 -122.08408} Bell Labs:{40.68433 -74.39967}]
with Vertex the type omitted.
It's different from my laptop, which shows:
map[Bell Labs:{40.68433 -74.39967} Google:{37.42202 -122.08408}]
In map-literals.go, your code shows
map[Bell Labs:{40.68433 -74.39967} Google:{37.42202 -122.08408}]
with Vertex as the type shown in the code.
Dwight
Context: https://tour.golang.org/moretypes/18
I think so You are missing: "functions include (x+y)/2, x*y, and x^y." in the function
Context: http://127.0.0.1:3999/methods/1
Change the title above to describe your issue and add your feedback here, including code if necessary
Current favicon link is broken and returns 404. This is not a first world problem but I wanted to report it and propose a fix.
Context: https://tour.golang.org/flowcontrol/10
fmt.Println(time.Now()) retuns 2009-11-10 23:00:00 +0000 UTC
while it is 2016-05-07 and 06:32 UTC
Context: https://tour.golang.org/methods/9
The incorrect comment on this page is actually on line 18.
so change
Note: There is an error in the example code on line 22. Vertex (the value type) doesn't implement Abser because the Abs method is defined only on *Vertex (the pointer type).
to
Note: There is an error in the example code on line 18. Vertex (the value type) doesn't implement Abser because the Abs method is defined only on *Vertex (the pointer type).
Context: https://tour.golang.org/welcome/2
it seems the remote server is not responding when using language translation :
Traditional Chinese — 中文(繁體)
which take you to link
https://go-tour-zh-tw.appspot.com/#1
When expecting an answer after hitting RUN its response UI text area flashes then goes blank when it should show result of Run ... other language translations seem OK
Interestingly, I am on the Opera browser and after above happened my opera sync became disconnected for the very first time ...
Context: http://localhost:8080/basics/5
Change the title above to describe your issue and add your feedback here, including code if necessary
Context: https://go-tour-de.appspot.com/welcome/
If one uses the German tour, the examples do not work. Clicking on "Run" just produces a quickly disappearing "Warte auf den Remoteserver …" (Engl.: Waiting for remote server).
Using Chromium 50.0.2661.102
The English tour works fine.
Context: https://tour.golang.org/moretypes/18
The question is vague, nowhere to verify the answer.
Thanks,
Context: https://tour.golang.org/welcome/4
In this section -fmt.Println("The time is", time.Now.nanoseconds())
is not working.
Error while compiling:
prog.go:11: time.Now.nanoseconds undefined (type func() time.Time has no field or method nanoseconds)
Context: https://tour.golang.org/welcome/3
The instructions suggest that downloading and installing Go allows the user to run the tour locally, but they do not mention that Go Tour project must also be installed.
Perhaps suggesting installation of Go and Go Tour with a link to the Go Tour project README for their installation and execution instructions would be helpful for folks wanting to run the tour locally.
Context: http://127.0.0.1:3999/basics/11
Should it be saying signed or unsigned interger
instead?
Context: https://tour.golang.org/moretypes/18
import golang.org/x/tour/pic
attemps to import the function from either $GOROOT or $GOPATH which results in the following error:
cannot find package "golang.org/x/tour/pic" in any of:
C:\Go\src\golang.org\x\tour\pic (from $GOROOT)
C:\Gocode\src\golang.org\x\tour\pic (from $GOPATH)
Apparently, the function resides in C:\Go\misc\tour\src\golang.org\x\tour\pic
so the import has an incorrect address.
Edit: apparently I had to go get golang.org/x/tour/pic
to get the import working.
Context: https://tour.golang.org/flowcontrol/1
"Javascript" should be spelled as "JavaScript"
In the Note:
Note: Unlike other languages like C, Java, or Javascript there are no parentheses surrounding the three components of the for statement and the braces { } are always required.
Created a PR here: #33
https://go-tour-de.appspot.com/welcome/1
All German code examples can't run, no outpus.
Context: https://tour.golang.org/moretypes/15 about slice of slices
Samples do not compile (it is maybe the exercise ?)
Slice of slices are authorized by specifications but are more complex to initialize.
Append does not work on an empty slice of slice.
If init is set with 1 element like board := [1][]int then append will work on board[0]
Another solution is to add slice notation to the added element and not the basic type element (0).
In example 15, printSlice cannot work if argument is not set to (s [][]int).
Could you confirm that slice of slices is supported ?
If yes, sample should look like this unless errors are the exercise.
`package main
import "fmt"
func main() {
var s [][]int
printSlice(s)
// append works on nil slices.
s = append(s, []int{0,})
printSlice(s)
// The slice grows as needed.
s[0] = append(s[0], 1)
printSlice(s)
// We can add more than one element at a time.
s[0] = append(s[0], 2, 3, 4)
s = append(s, []int{2, 3, 4,}) //or add a separate slice
printSlice(s)
}
func printSlice(s [][]int) {
fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
}`
Would be super awesome if users could tab complete or get a description of what the functions are actually doing.
Running though some of these examples, I'm fluxing with the examples and curious to see what else is supposed with these imported libraries.
Something similar to how ipython does it would be utterly fantastic!
Context: https://tour.golang.org/basics/15
Change the title above to describe your issue and add your feedback here, including code if necessary
Would it be possible to make the "Table of contents" pane dock right? It disappears when you click on the code area. It would be nice if it stays open for easy navigation.
Thanks
I notice the french version of Golang Tour returns empty response when executing code. I try other languages and found other "broken" versions:
Run Hello.go
A correct output :
Hello, 世界
Program exited.
An empty response:
Program exited.
Language | Code execution | Available |
---|---|---|
Brazilian Portuguese — Português do Brasil | ok | ok |
Catalan — Català | ok | ok |
German — Deutsch | FAIL | ok |
Spanish — Español | ok | ok |
French — Français | FAIL | ok |
Indonesia — Bahasa | ok | ok |
Italian — Italiano | ok | ok |
Hebrew — עִבְרִית | ok | ok |
Japanese — 日本語 | ok | ok |
Korean — 한국어 | ok | ok |
Romanian — Română | ok | ok |
Simplified Chinese — 中文(简体) | ok | ok |
Traditional Chinese — 中文(繁體) | ok | ok |
Ukrainian — Українська | FAIL | ok |
Uzbek — Ўзбекча | FAIL | ok |
Turkish - Türkçe | FAIL | FAIL |
The turkish domain isn't resolving.
On a tour page like this, if we replaced
fmt.Println("Hello, 世界")
with
fmt.Println("The output message cannot be wrapped correctly if it is too long. [This message can not be displayed completely below.]")
the bug will be triggered.
Hi,
I am a newbie to GO.
Context: https://tour.golang.org/basics/1
When I try executing the sample code the output is always My favorite number is 1, shouldn't it randomize the number?
Confirmed the same by executing the tour in another machine locally (go tools tour).
Context: https://tour.golang.org/list
Change the title above to describe your issue and add your feedback here, including code if necessary
Context: https://tour.golang.org/moretypes/7
Hi,
following is also possible: []int{2, 3, 5, 7, 11, 13}
Why do you use the array size[6}. Is there any advanzage to use it ?
Context: https://go-tour-jp.appspot.com/welcome/1
Change the title above to describe your issue and add your feedback here, including code if necessary
Context: https://tour.golang.org/methods/9
Since, both the variables f & v of different types, implement the Abser interface, I think it would be good to print f.Abs() too to the console, to make the user understand how 2 different values are printed, due to 2 different methods specific to their respective type.
Change would be to add,
fmt.Println(f.Abs()) at the end of the main function.
Context: https://tour.golang.org/moretypes/15
If the backing array of s is too small to fit all the given values a bigger array will be allocated. The returned slice will point to the newly allocated array.
It would be useful to understand at what cost this newly created array would be. How does Go handle garbage collection is situations like this? What happens to the old array?
This might be outside of the scope of a tutorial, but I would find a sentence or two on what happens to the old array useful.
Cheers!
Context: http://tour.golang.org/moretypes/7
Open from internal bug
I was going through the Go Tour and got to your explanation of slices: http://tour.golang.org/moretypes/7
It says, "A slice points to an array of values and also includes a length." That makes it sounds like a Slice is an Array with a length value – which I'm pretty sure is wrong. Arrays' types have lengths and slices' don't have lengths (see http://blog.golang.org/go-slices-usage-and-internals which says "Unlike an array type, a slice type has no specified length.")
Apologies if 1) I'm just misunderstanding – entirely possible – or 2) this is the wrong component to file the bug
Steps to reproduce:
Like an array of size 100 filled with value -1 in C++.
eg: std::fill_n(array, 100, -1);
The same thing I want to do in Go.
array := make([]int, 100)
how to fill it with -1 in one line?
https://tour.golang.org/basics/11
Title: Basic type
func main() {
const f = "%T(%v)\n"
fmt.Printf(f, ToBe, ToBe)
fmt.Printf(f, MaxInt, MaxInt)
fmt.Printf(f, z, z)
}
Here the value assigned to const f is very confusing. There has been no reference to %T and %v prior to this.
I spent a long time wondering what the output implied.
Could we have a string as simple as " Type : %T , Value : %v \n " instead of "%T(%v)\n" for the sake of better understanding and readability.
I could open a PR for this right away.
Context: https://tour.golang.org/listoo o o IP oomm imo 9i8 o m ökologische o
Change the title above to describe your issue and add your feedback here, including code if necessary
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.