[go-nuts] Why Go has only slice and map

2022-04-11 Thread 'Jack Li' via golang-nuts
Hi group, Why Go provides only 2 built-in data structures, slice and map. It has just more than C, but less than all other programming languages I've heard of, C++, Python, Swift, Rust.  I think this simplicity attracts me very much. Sometimes I can use only one data structures for a task. B

Re: [go-nuts] float exactness

2022-04-09 Thread 'Jack Li' via golang-nuts
Thanks Robert, It is great! a, _ := decimal.NewFromString("0.1") b, _ := decimal.NewFromString("0.2") c := a.Add(b) fmt.Println("decimal:", c) a = decimal.NewFromFloat(0.1) b = decimal.NewFromFloat(0.2) c = a.Add(b) fmt.Println("

[go-nuts] float exactness

2022-04-09 Thread 'Jack Li' via golang-nuts
Hi group, 1.  Is there a package can do exact float operations, like Decimal in Python? For example: x := 0.1; y := 0.2; z := x + y; z will be exact 0.3 2. Why literal operation is exact, variable is not? fmt.Println(0.1 + 0.2) // 0.3 exactly fmt.Println(x + y) // 0.30004

Re:[go-nuts] Re: MaxDiskSize MaxLogCount for glog?

2022-04-09 Thread 'Jack Li' via golang-nuts
Is it still maintained? The last commit is Aug 20, 2021 which is more than half year ago. The last commit of glog in C++ is just 5 days ago. -- Original -- From: "peterGo"https://github.com/golang/glog#glog   "The code in this repo is for export only and i

Re: [go-nuts] Missing /usr/lib/go/pkg/include/ for native binaries

2022-04-07 Thread 'Jack Li' via golang-nuts
Yes, I download the latest go 1.18 installer for macOS from golang.google.cn. There's no problem with the installer from the official site. -- Original -- From: "Ian Lance Taylor"http://deb.debian.org/debian bullseye-backports/main amd64 Packages >  *** 1.17.6-1

[go-nuts] MaxDiskSize MaxLogCount for glog?

2022-04-07 Thread 'Jack Li' via golang-nuts
Hi group, I only find MaxSize in glog which sets the size of each log file.  Can glog support the options like how many disk size (ie. 10%, 1.8G, etc.) all the log files may use in total, and the count (ie. 10) of log files it can save. For example, logfile1.txt, logfile2.txt, ..., logfile10.

Re:[go-nuts] Re: How go.work knows which module refers to which folder

2022-04-06 Thread 'Jack Li' via golang-nuts
Thanks. I think I may get it. If there's go.work, the `import example.com/module` will try those local directories in go.work first. If not found, it will try online repositories. And module names like this `example.com/module`, `github.com/golang/glog`, etc. are unique, so there will be no

[go-nuts] How go.work knows which module refers to which folder

2022-04-06 Thread 'Jack Li' via golang-nuts
Hi group, In the go.mod replace way, there’s a one-to-one mapping relationship, for example, the module example.com/hello is mapped to folder …/hello ``` $ go mod edit -replace example.com/hello=../hello $ view go.mod replace example.com/hello => ../hello  $ ``` Now with the go.work way. If

[go-nuts] Handle 1 million concurrent connections with 50 lines Go code

2022-04-06 Thread 'Jack Li' via golang-nuts
Hi group, I am going through this page: https://studygolang.com/articles/22820 , It claims that the 50 lines of Go code handles 1 million concurrent connections from network clients, on 1 single server machine with a 4-Core CPU and 16G memory. Does the package net already utilize IO Multiple