- 第 53958 位会员
- 2020-06-14 16:15:10
- 77 46
评论了主题 Go语言爱好者周刊：第 86 期* [The Go Programming Language Specificatio - Representability](https://golang.org/ref/spec#Representability) > A constant x is representable by a value of type T if one of the following conditions applies: > > x is in the set of values determined by T. T is a floating-point type and x can be rounded to T's precision without overflow. Rounding uses IEEE 754 round-to-even rules but with an IEEE negative zero further simplified to an unsigned zero. Note that constant values never result in an IEEE negative zero, NaN, or infinity. T is a complex type, and x's components real(x) and imag(x) are representable by values of T's component type (float32 or float64). * [The Go Blog - Constants](https://blog.golang.org/constants) > The concept of untyped constants in Go means that all the numeric constants, whether integer, floating-point, complex, or even character values, live in a kind of unified space. It's when we bring them to the computational world of variables, assignments, and operations that the actual types matter. But as long as we stay in the world of numeric constants, we can mix and match values as we like. > A constant may be given a type explicitly by a constant declaration or conversion, or implicitly when used in a variable declaration or an assignment or as an operand in an expression. It is an error if the constant value cannot be represented as a value of the respective type. > An untyped constant has a default type which is the type to which the constant is implicitly converted in contexts where a typed value is required, for instance, in a short variable declaration such as i := 0 where there is no explicit type. The default type of an untyped constant is bool, rune, int, float64, complex128 or string respectively, depending on whether it is a boolean, rune, integer, floating-point, complex, or string constant. 无类型常量（untyped constant）2.0被转为rint32类型值2； （int32)98/(int32)2 = (int32)49
评论了主题 Go语言爱好者周刊：第 85 期## [Golang通道类型定义](https://golang.org/ref/spec#Channel_types) > The <- operator associates with the leftmost chan possible: > ```golang chan<- chan int // same as chan<- (chan int) chan<- <-chan int // same as chan<- (<-chan int) <-chan <-chan int // same as <-chan (<-chan int) chan (<-chan int) ``` 所以题目中： > ```golang var x chan<-chan error // nil 类型：chan<- (chan error) var y chan(<-chan error) // nil 类型：chan (<-chan error) ``` ## [Golang比较规范](https://golang.org/ref/spec#Comparison_operators) > In any comparison, the first operand must be assignable to the type of the second operand, or vice versa. ## [Golang可赋值规范](https://golang.org/ref/spec#Assignability) 结论： 类型不同，且不可相互赋值，无法进行比较。 【C：无法编译】
评论了主题 Go语言爱好者周刊：第 79 期3楼 @tky753 是的，'e'的编码不一样 第一个еrr：`[208 181 114 114]` , е编码`[208 181]` 第二个err：` [101 114 114]` ,e 编码 `` [play.studygolang.com](https://play.studygolang.com/p/SQP70DAFGHh)
评论了主题 Go语言爱好者周刊：第 78 期[Goroutines](https://tour.golang.org/concurrency/1) ```go go f(x, y, z) ``` > The **evaluation of f, x, y, and z happens in the current goroutine** and the execution of f happens in the new goroutine.
```shell go run [build flags] [-exec xprog] package [arguments...] ``` Run compiles and runs the named **main** Go package. Typically the package is specified as **a list of .go source files** from a single directory, but it may also be an import path, file system path, or pattern matching a single known package, as in 'go run .' or 'go run my/cmd'. [go run](https://golang.org/cmd/go/#hdr-Compile_and_run_Go_program)