hyper0x / golang_puzzlers Goto Github PK
View Code? Open in Web Editor NEWAn example project, for my column named "Core Golang - 36 lessons"
An example project, for my column named "Core Golang - 36 lessons"
下边的61行也应该循环max1次,从sign中取值
# cat demo21.go
package main
func main() {
// 示例1。
ch1 := make(chan int, 1)
ch1 <- 1
//ch1 <- 2 // 通道已满,因此这里会造成阻塞。
// 示例2。
ch2 := make(chan int, 1)
//elem, ok := <-ch2 // 通道已空,因此这里会造成阻塞。
//fmt.Printf("%v, %v", elem, ok)
//_, _ = elem, ok
ch2 <- 1
// 示例3。
var ch3 chan int
//ch3 <- 1 // 通道的值为nil,因此这里会造成永久的阻塞!
//<-ch2 // 通道的值为nil,因此这里会造成永久的阻塞! ----> 这个ch2是不是要改成ch3呢
_ = ch3
}
在 demo48 中,说明了控制权会一级一级地沿着调用栈的反方向传播至顶端。我就把代码改了改,变成了python,发现是和go的传播方式是反着的。这两种方式只是设计思路的差异吗?还是说,因为我这段 python 是面向过程的,所以,就展示的是这样?
求郝大或者其他大神解答
#!/usr/bin/python
def main():
print "Enter function main."
caller1()
print "Exit function main."
def caller1():
print "Enter function caller1."
caller2()
print "Exit function caller1."
def caller2():
print "Enter function caller2."
s1 = [0, 1, 2, 3, 4]
e5 = s1[5]
print "Exit function caller2. "
main()
这些是打印结果:
Enter function main.
Enter function caller1.
Enter function caller2.
Traceback (most recent call last):
File "demo48.py", line 18, in
main()
File "demo48.py", line 4, in main
caller1()
File "demo48.py", line 9, in caller1
caller2()
File "demo48.py", line 15, in caller2
e5 = s1[5]
IndexError: list index out of range
08 container包中的那些容器 => article8 这节的代码没有看到
21 | panic函数、recover函数以及defer语句 (上)https://time.geekbang.org/column/article/40359
里面提到demo47,但文件夹里是demo55
in line 37, test func name is wrong, testIntroduce func missed 't' in function name
老师,我有一个疑问(在极客时间以及提问过了,不过不知道您是否还维护那个专栏所以在这里向您提问),对于cond来说,每次只唤醒一个goruntine,如果这么goruntine发现消息不是自己想要的就会从新阻塞在wait函数中,那么真正需要这个消息的goruntine还会被唤醒吗?
.\demo4.go:15:2: undefined: hello
Compilation finished with exit code 2
同一个package下的函数无法识别,求助!
GoHackers 项目当前人员已满,劳烦大佬帮忙处理一下
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.