Giter VIP home page Giter VIP logo

learning-go-zh-cn's Issues

二维数组定义, 范围设定问题

原来代码是这样:

a := [2][2]int{ {1,2}, {3,4} }

但是哪个 2 和哪个对应就存在问题了... 建议换掉一个 2
虽然测试代码显示前边的 2 对应外层花括号

make执行成功,但是没有生成html文件

cosmo:mmark cosmo$ make 2.0.46 go build
cosmo:mmark cosmo$ ls LICENSE internal mmark.go rfc Makefile mast mmark_man_test.go rfc_test.go README.md mmark mmark_markdown_test.go schema Syntax.md mmark.1 mmark_test.go testdata go.mod mmark.1.docheader mparser version.go go.sum mmark.1.md render
bin下面找了也没有
然后我又执行了一下生成的mmark没有反应

请问并发章节的 Q26 (1) channel 第二题的答案是否有问题?

这一题的答案在这里:

https://github.com/mikespook/Learning-Go-zh-cn/blob/master/ex-channels/src/for-quit-chan.go

它的代码是这样的:

func main() {
	ch := make(chan int)
	quit := make(chan bool)
	go shower(ch, quit)
	for i := 0; i < 10; i++ {
		ch <- i
	}
	quit <- false	// 或者是 true,这没啥关系
}

func shower(c chan int, quit chan bool) {
	for {
		select {
		case j := <-c:
			fmt.Printf("%d\n", j)
		case <-quit:
			break
		}
	}
}

main 程序在将false写入quitchannel后就退出了,此时是不是仍然有可能shower Goroutine 没有从quit中接收到值,整个程序已经结束了。

我感觉这个逻辑应该是show Goroutine 写入值到quitchannel中,然后main再等待结束吧。

package main

import "fmt"

func show(ch chan int, quit chan bool) {
	for {
		val, ok := <-ch
		if !ok {
			break
		}
		fmt.Println("Get the", val)
	}

	quit <- true
}

func main() {
	ch := make(chan int)
	quit := make(chan bool)

	go show(ch, quit)
	for i := 0; i < 10; i++ {
		ch <- i
	}
	close(ch)

	<-quit
}

函数一章中答案 A10 关于斐波那契函数的问题

func fibonacci(value int) []int {
    x := make([]int, value)
    x[0], x[1] = 1, 1
    for n := 2; n < value; n++ {
        x[n] = x[n-1] + x[n-2]
    }
    return x
}

原函数在参数为1时会报错

func fibonacci(n int) []int {
    arr := make([]int, n)
    a, b := 0, 1
    for i := 0; i < n; i++ {
        a, b = b, a+b
        arr[i] = a
    }
    return arr
}

参考了:fib.go

flag.CommandLine.Output undefined

在ubuntu环境下, go version go1.2.1 linux/386, 执行go get github.com/mmarkdown/mmark报错:flag.CommandLine.Output undefined (type *flag.FlagSet has no field or method Output)

很奇怪现在Golang都是1.12.4版本了,为啥我的ubuntu 重新apt-get的版本还是1.2.1?

找不到邮箱,只好留这了

你好,我对go语言很感兴趣,想学习一下 plan9的汇编器和编译器,但是看完plan9首页的文档以后还是比较懵,现在看一些汇编的代码有一些命令总是查不到,比如MOVOU这样的,还有一些语法什么的,我能从哪里获取更丰富的文档么,我的汇编学的不多,勉勉强强在看得懂一些代码,能从哪里补充这些汇编的知识么?

文件不全

编译之后的 html 打开只有前言和基础的一部分,看代码,master 分支中 md 文件也只有这两个,是文件删了还是我打开方式不对?

page 57 sample codes can not pass compile.

In my compiler, the following Enone/Einvalid are marked as RED, and cannot pass compile. I think the arr and sl shall not include them, and in map they shall be string? or you want to show other thing here?

arr := [...]string{Enone: "no error", Einvalid:"invalid argument"}
sl :=[]string{Enone: "no error", Einvalid:"invalid argument"}
ma :=map[int]string{Enone: "no error", Einvalid:"invalid argument"}

make failed to create the learninggo.html

Hi there ,

I try to make this project to get the file of learninggo.html as it is from ots makefile . But, after i downloaded and did a make with a failed output as follows .

BR
Michael
DATE:2018-12-23

======
C:\Learning-Go-zh-cn>make
mmark -html -head inc/head.html -css inc/book.css learninggo.md > learninggo.html
767 [main] make 5952 fork: child 20552 - died waiting for dll loading, errno 11
make: fork: Resource temporarily unavailable

C:\Learning-Go-zh-cn>dir
Volume in drive C is Windows
Volume Serial Number is 76ED-D0DB

Directory of C:\Learning-Go-zh-cn

12/23/2018 08:31 PM

.
12/23/2018 08:31 PM ..
12/23/2018 08:31 PM 12 .gitignore
12/23/2018 08:31 PM basics
12/23/2018 08:31 PM fig
12/23/2018 08:31 PM inc
12/23/2018 08:31 PM introduction
12/23/2018 08:31 PM 560 learninggo.md
12/23/2018 08:31 PM 294 LICENSE
12/23/2018 08:31 PM 842 Makefile
12/23/2018 08:31 PM 4,625 preface.md
12/23/2018 08:31 PM 890 README.md
12/23/2018 08:31 PM src
6 File(s) 7,223 bytes
7 Dir(s) 13,141,250,048 bytes free

C:\Learning-Go-zh-cn>

A suggestion on src code

it will be better if change the line 7 in ex-basics/src/stringrev.go

a := []byte(s) |\coderemark{Again a conversion}|

to

a := []rune(s) |\coderemark{Again a conversion}|

“保留字”翻译是否得当?

Hi,Mike!

很喜欢这个项目,我正在通过它来学习Go语言,非常感谢你的无私奉献!
有一个问题困挠我,我发现项目中的关键字都使用保留字作为翻译。我的理解是关键字是正在使用的保留字,而保留字更倾向于现在未使用留待将来扩展的字。
是否将其翻译为“关键字”更为得当呢?个人愚见,如有不妥望指正!

Thanks again for your work!

How to use |\longremark{ } |

vim vimLearning-Go-zh-cn/ex-basics/src/fizzbuzz.go, then I found:
const (
FIZZ = 3 |\longremark{为了提高代码的可读性,定义两个常量。%
参阅``\titleref{sec:constants}'';}|
BUZZ = 5
)
And how to use |\longremark{ }| ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.