mactsouk / mastering-go-3rd Goto Github PK
View Code? Open in Web Editor NEWSource code for Mastering Go, 3rd edition
Source code for Mastering Go, 3rd edition
mastering-Go-3rd/ch04/errorInt.go
Line 46 in 442798c
//fixing syntax error on numeric.go (ch13) line 8:
package main
import (
"fmt"
)
type Numeric interface {
int | int8 | int16 | int32 | int64 | float64
}
func Add[T Numeric](a, b T) T {
return a + b
}
func main() {
fmt.Println("4 + 3 =", Add(4,3))
fmt.Println("4.1 + 3.2 =", Add(4.1,3.2))
}
From:
mastering-Go-3rd/ch06/signals.go
Lines 27 to 31 in 481348d
Why is os.Exit()
called for SIGINFO
. I tried this locally with SIGUSR1
and executing:
$ kill -USR1 <pid>
caused the complete process to exit not just the go routine. The <pid>
didn't exist anymore and the process had terminated.
When I tried the same example by commenting out os.Exit()
, it worked perfectly fine and the for
loop was still continuing and the go routine hadn't exited.
I am on Ch-06 right now so my knowledge about goroutines and channels is limited.
Why isn't the code for chap 12 available?
When implementing the GetRandom
method you are suddenly using a function method(min, max)
.
Where is this function coming from? What are min
and max
?
mastering-Go-3rd/ch01/forLoops.go
Line 14 in 5607344
func Same[T comparable](a, b T) bool {
if a == b {
return true
}
return false
}
as
func Same[T comparable](a, b T) bool {
return a == b
}
@mactsouk may be not a big deal here as you are explaining about generics?
mastering-Go-3rd/ch05/getSchema.go
Line 61 in 442798c
with the line 47 of the code sliceArrays.go,it says:
// This change does not go to S12
a[1] = "-N2-"
but Actually, the changes of a[1] does go to S12 !
By the way , the Book is right: "However, array a and slice S12 are still connected because the capacity of S12 has not
changed."
mastering-Go-3rd/ch03/phoneBook.go
Line 163 in 233d6c9
In the book it's written about this code:
The preceding naively implemented example creates 4 go-routines
However there 5 go-routines created in the actual code (other than main
) indexed: 0, 1, 2, 3, 4
mastering-Go-3rd/ch01/goRoutines.go
Line 17 in 5607344
When the first argument is non-parseable, the min
/max
variables are not initialized to the first parseable argument (but to 0 by default). This would lead to bug when all the parseable arguments share the same sign.
Line 23 in 5607344
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.