Re: [go-nuts] Go 2 suggestion - Types like "int?"
I don't think it's immediately obvious what use cases this "int?" proposal delivers that aren't covered by "*int". The encoding/json package uses pointers to support null JSON values. As a more general point, when someone answers your question, they're taking time out of their day to help you. I think it's reasonable for the burden of proof to be put upon the asker, who is looking to others for help. On Sat, Aug 19, 2017 at 9:28 PM Tong Sunwrote: > Oh yeah? Are you sure what you are answering is what I'm asking? > > Please try to understand what people are asking before showing off > yourself, or post concrete example to proof that you understand correctly > what people are asking. > > On Sat, Aug 19, 2017 at 4:02 PM, Axel Wagner < > axel.wagner...@googlemail.com> wrote: > >> Go can do what you want today, just that it's spelled "*int". >> >> On Sat, Aug 19, 2017 at 6:01 PM, Tong Sun wrote: >> >>> - "int?" will be a different type than "int". I.e., we know very well >>> what we are sacrificing when we choose that type. >>> - There is a demand there, json and/or sql. Denying it won't make it go >>> away. >>> >>> (*Sorry to Jan, was sending to the wrong place*) >>> >>> On Sat, Aug 19, 2017 at 11:54 AM, Jan Mercl <0xj...@gmail.com> wrote: >>> On Sat, Aug 19, 2017 at 5:05 PM Tong Sun wrote: > Suggesting C# type syntax like "int?" so as to take nil as valid value. - As int is not a pointer type, what would nil int mean? - Are you willing to sacrifice extra storage for the additional isNil information or do you prefer that int cannot represent 2^(sizeof(int)*8) different values? - (xyproblem?) If you need the information like 'isValid', why a separate bool [field] is not enough? -- -j >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "golang-nuts" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to golang-nuts+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] when to switch a goroutine to be executed
Hi guys, I am learning golang with the fantastic book "Go in Action". And I have some problems with understanding when to switch a goroutine to be run in chapter 6. package main 1 2 import ( 3 "fmt" 4 "runtime" 5 "sync" 6 ) 7 8 func main() { 9 runtime.GOMAXPROCS(1) 10 11 var wg sync.WaitGroup 12 wg.Add(2) 13 // first goroutine 14 go func() { 15 defer wg.Done() 16 for c := 0; c < 3; c++ { 17 for char := 'a'; char < 'a'+26; char++ { 18 fmt.Printf("%c", char) 19 } 20 } 21 fmt.Println("") 22 }() 23 // second goroutine 24 go func() { 25 defer wg.Done() 26 for c := 0; c < 3; c++ { 27 for char := 'A'; char < 'A'+26; char++ { 28 fmt.Printf("%c", char) 29 } 30 } 31 fmt.Println("") 32 }() 33 34 wg.Wait() } Why the result is printing uppercase letters first? I mean the two goroutines are passed in a waiting queue in order of the time they were generated, and they were meant to be executed in the same order. So why the second goroutine got executed first? Or is the fmt.Println method is IO-related? Please help me understand this situation. Thanks! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Go 2 suggestion - Types like "int?"
Oh yeah? Are you sure what you are answering is what I'm asking? Please try to understand what people are asking before showing off yourself, or post concrete example to proof that you understand correctly what people are asking. On Sat, Aug 19, 2017 at 4:02 PM, Axel Wagnerwrote: > Go can do what you want today, just that it's spelled "*int". > > On Sat, Aug 19, 2017 at 6:01 PM, Tong Sun wrote: > >> - "int?" will be a different type than "int". I.e., we know very well >> what we are sacrificing when we choose that type. >> - There is a demand there, json and/or sql. Denying it won't make it go >> away. >> >> (*Sorry to Jan, was sending to the wrong place*) >> >> On Sat, Aug 19, 2017 at 11:54 AM, Jan Mercl <0xj...@gmail.com> wrote: >> >>> On Sat, Aug 19, 2017 at 5:05 PM Tong Sun wrote: >>> >>> > Suggesting C# type syntax like "int?" so as to take nil as valid >>> value. >>> >>> - As int is not a pointer type, what would nil int mean? >>> >>> - Are you willing to sacrifice extra storage for the additional isNil >>> information or do you prefer that int cannot represent 2^(sizeof(int)*8) >>> different values? >>> >>> - (xyproblem?) If you need the information like 'isValid', why a >>> separate bool [field] is not enough? >>> >>> -- >>> >>> -j >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] License for x/image/testdata and x/image/font/testdata files
On Thu, Aug 17, 2017 at 5:13 AM, Ian Lance Taylorwrote: > On Wed, Aug 16, 2017 at 11:50 AM, wrote: >> I was wondering if I should assume BSD 3 clause licenses for all the files >> located under >> >> x/image/testdata and x/image/font/testdata >> >> since there are no licese notes regarding those files (fonts and images). For x/image/font/testdata, the three fonts directly in that directory (in .sfd and .otf / .ttf format) are original works by the Go Authors, so they use the BSD 3 clause license like the rest of the repo. For the x/image/font/testdata/fixed subdirectory, there is a README that contains license notes. For x/image/testdata, I think "git log" is the best source of per-file license notes. For example: $ git log testdata/tux.png commit 94ba43c4786221df328229f694fa73a71558583b Author: Nigel Tao Date: Tue Jun 17 21:51:57 2014 +1000 go.image/vp8l: new package. The blue-purple-pink image comes from http://blog.golang.org/gophercon The tux and yellow_rose images come from https://developers.google.com/speed/webp/gallery2 and according to that page, those images are in the public domain. The gopher-doc images are http://golang.org/doc/gopher/doc.png after quantizing its palette to 2/4/16/256 colors. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/109010043 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Type findfuncbucket shown from gdb
Hey guys, sorry for bothering :D Here I want to ask a small question about the Golang binary debug info. The steps to reproduce my problem: 1. $ cat symtab.go ``` package main import ( "fmt" "net/http" _ "net/http/pprof" "os" ) func main() { fmt.Println(os.Getpid()) http.ListenAndServe(":9990", nil) } ``` 2. $ go build symtab.go 3. $ ./main` 4. $ gdb -pid $THE-PID 5. (gdb) i types findfuncbucket All types matching regular expression "findfuncbucket": Here I wonder the type `findfuncbucket` was defined in https://github.com/golang/go/blob/ff90f4af66c30a819532fda8754bf29e8ae6140e/src/runtime/symtab.go#L498. So I guess it should show up here like ``` (gdb) i types runtime.bucket All types matching regular expression "runtime.bucket": File go: struct runtime.bucket; typedef runtime.bucketType; struct struct { F uintptr; p unsafe.Pointer; b *runtime.bucket }; ``` would show the type `runtime.bucket` defined in https://github.com/golang/go/blob/ff90f4af66c30a819532fda8754bf29e8ae6140e/src/runtime/mprof.go#L48 So what did I miss here? :D Thanks! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Go 2 suggestion - Types like "int?"
Go can do what you want today, just that it's spelled "*int". On Sat, Aug 19, 2017 at 6:01 PM, Tong Sunwrote: > - "int?" will be a different type than "int". I.e., we know very well what > we are sacrificing when we choose that type. > - There is a demand there, json and/or sql. Denying it won't make it go > away. > > (*Sorry to Jan, was sending to the wrong place*) > > On Sat, Aug 19, 2017 at 11:54 AM, Jan Mercl <0xj...@gmail.com> wrote: > >> On Sat, Aug 19, 2017 at 5:05 PM Tong Sun wrote: >> >> > Suggesting C# type syntax like "int?" so as to take nil as valid value. >> >> - As int is not a pointer type, what would nil int mean? >> >> - Are you willing to sacrifice extra storage for the additional isNil >> information or do you prefer that int cannot represent 2^(sizeof(int)*8) >> different values? >> >> - (xyproblem?) If you need the information like 'isValid', why a separate >> bool [field] is not enough? >> >> -- >> >> -j >> > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] golang continuous deployment & gitlab
Hi I have a golang HTTP server that I am deploying on an AWS EC2 VM, as a systemd service. Right now, I am manually deploying the service as follows: 1) vm$ sudo systemctl stop 2) dev$ scp 3)psql$ Apply migrations manually 4) vm$ sudo stystemctl start 4) vm$ sudo stystemctl status ;# Just to check I maintain my sources in gitlab and my database is postgres. I am planning to use gitlab-ci for preparing cross-compiled systemd binaries and also sqitch for postgres migrations. I wanted to ask if there are any advises (or links to tools/blogposts/scripts) from existing gitlab (or even github+ci) + golang users, who do continuous deployments already. I can have some downtime and 100% uptime is not important for me. Also, one instance of my server is enough and there is no need for HA, load-balancing, etc. as of now, as it is just an internal low-traffic service. I also thought of preparing an ubuntu ppa repository internally, on the lines of https://about.gitlab.com/2016/10/12/automated-debian-package-build-with-gitlab-ci/ I am not using Docker (containers) because I do not want another layer which may cause some unknown problems (performance, networking, etc.) which I do not want to end up debugging. Any advises or suggestions or links that would help me ? Thanks. Sankar -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] multiply and divide
Awesome, thanks! I just can't match "arbitrary precision" and "float" expressions: 1/3 is rational, but can't be represented with float-like data structure. The same problem is with arbitrary precision uint: what will ^uint-1 be? So, arbitrary precision int and user-specified-precision float is great and wanted, but arbitrary precision uint and float is nonsense. On 2017. aug. 19., Szo 19:27 Michael Joneswrote: > Jimmy, thank you for the tip! i went there and added my modest suggestions > to the proposal. > https://github.com/golang/go/issues/19623 > > Tamás, you make a very important point. It is one that GRI did a very good > job of in big.Float. The question of how to specify precision for > variable-precision floating point math is tricky. He does it by making each > variable carry a precision, allows users to change this, and has rules for > the precision of results of operations between values of same or differing > precisions. > > One implication of this issue is in handling something like 1/3. I have > software that converts such expressions to big.rat and then once the target > big.float exists with its chosen precision, does the conversion. In one of > these cases I have three different extended precisions going in the same > application, one for parameters (50 digits plus guard digits), one for > computation (less or more depending on dynamic precision needs), and one > fast and tuned doubled-precision (128-bit float) for very intensive inner > computations. > > Situations like this make it a little complicated for fractions and also > for constants (Pi, Tau, E, ...), which are no longer constants but must be > functions since they need to work more or less based on the precision of > the desired result. > > A little messy. > > On Sat, Aug 19, 2017 at 10:03 AM, Tamás Gulácsi > wrote: > >> What is an arbitrary precision float? 1/3, Pi, ✓2 ? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Michael T. Jones > michael.jo...@gmail.com > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] multiply and divide
Jimmy, thank you for the tip! i went there and added my modest suggestions to the proposal. https://github.com/golang/go/issues/19623 Tamás, you make a very important point. It is one that GRI did a very good job of in big.Float. The question of how to specify precision for variable-precision floating point math is tricky. He does it by making each variable carry a precision, allows users to change this, and has rules for the precision of results of operations between values of same or differing precisions. One implication of this issue is in handling something like 1/3. I have software that converts such expressions to big.rat and then once the target big.float exists with its chosen precision, does the conversion. In one of these cases I have three different extended precisions going in the same application, one for parameters (50 digits plus guard digits), one for computation (less or more depending on dynamic precision needs), and one fast and tuned doubled-precision (128-bit float) for very intensive inner computations. Situations like this make it a little complicated for fractions and also for constants (Pi, Tau, E, ...), which are no longer constants but must be functions since they need to work more or less based on the precision of the desired result. A little messy. On Sat, Aug 19, 2017 at 10:03 AM, Tamás Gulácsiwrote: > What is an arbitrary precision float? 1/3, Pi, ✓2 ? > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Michael T. Jones michael.jo...@gmail.com -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] multiply and divide
What is an arbitrary precision float? 1/3, Pi, ✓2 ? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] multiply and divide
There's https://github.com/golang/go/issues/19623 for making int arbitrary precision in Go2 (yes, please) there could also be an arbitrary precision float to go with float32/float64 :D On Sat, Aug 19, 2017 at 8:04 AM, Michael Joneswrote: > I would REALLY like to see big types as normal declarations and syntax. The > SSA framework seems suitable to automatically manage the temporaries. > > On Sat, Aug 19, 2017 at 7:14 AM, roger peppe wrote: >> >> Constructive reals in Go, anyone? :-) >> >> On 18 Aug 2017 17:50, "Michael Jones" wrote: >>> >>> Here is a minor musing from something that came up yesterday. >>> >>> Sometimes we see a real number expression as simple as... >>> >>> x*y/z >>> >>> ...and knowing from basic algebra that... >>> >>> (x*y)/z == x*(y/z) >>> >>> ...we might not expect much difference between the two in our code. Alas, >>> computer floating point does not involve real numbers, rather it uses an >>> approximation of them. If you will copy https://play.golang.org/p/IlDxtvx7IY >>> to your computer, build and run it, (too much CPU for the playground) you'll >>> find that the order makes a difference. Or, you can just remember this >>> phrase, "multiply first, then divide." >>> >>> -- >>> Michael T. Jones >>> michael.jo...@gmail.com >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "golang-nuts" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to golang-nuts+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. > > > > > -- > Michael T. Jones > michael.jo...@gmail.com > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Go 2 suggestion - Types like "int?"
- "int?" will be a different type than "int". I.e., we know very well what we are sacrificing when we choose that type. - There is a demand there, json and/or sql. Denying it won't make it go away. (*Sorry to Jan, was sending to the wrong place*) On Sat, Aug 19, 2017 at 11:54 AM, Jan Mercl <0xj...@gmail.com> wrote: > On Sat, Aug 19, 2017 at 5:05 PM Tong Sunwrote: > > > Suggesting C# type syntax like "int?" so as to take nil as valid value. > > - As int is not a pointer type, what would nil int mean? > > - Are you willing to sacrifice extra storage for the additional isNil > information or do you prefer that int cannot represent 2^(sizeof(int)*8) > different values? > > - (xyproblem?) If you need the information like 'isValid', why a separate > bool [field] is not enough? > > -- > > -j > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Go 2 suggestion - Types like "int?"
On Sat, Aug 19, 2017 at 5:05 PM Tong Sunwrote: > Suggesting C# type syntax like "int?" so as to take nil as valid value. - As int is not a pointer type, what would nil int mean? - Are you willing to sacrifice extra storage for the additional isNil information or do you prefer that int cannot represent 2^(sizeof(int)*8) different values? - (xyproblem?) If you need the information like 'isValid', why a separate bool [field] is not enough? -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Go 2 suggestion - Types like "int?"
Suggesting C# type syntax like "int*?*" so as to take nil as valid value. Currently: var i int i = nil will give: cannot use nil as type int in assignment However, more and more people are using json to transport data, and there will be times that json may be invalid. I.e., the "int" type has 'null' as input. This is causing tremendous problems for me so far, as I have to jump over the hoops to deal with them. In C#, just by adding a "?" to the end of the type solves the problem. Please consider. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] multiply and divide
I would REALLY like to see big types as normal declarations and syntax. The SSA framework seems suitable to automatically manage the temporaries. On Sat, Aug 19, 2017 at 7:14 AM, roger peppewrote: > Constructive reals in Go, anyone? :-) > > On 18 Aug 2017 17:50, "Michael Jones" wrote: > >> Here is a minor musing from something that came up yesterday. >> >> Sometimes we see a real number expression as simple as... >> >> x*y/z >> >> ...and knowing from basic algebra that... >> >> (x*y)/z == x*(y/z) >> >> ...we might not expect much difference between the two in our code. Alas, >> computer floating point does not involve real numbers, rather it uses an >> approximation of them. If you will copy https://play.golang.org/p >> /IlDxtvx7IY to your computer, build and run it, (too much CPU for the >> playground) you'll find that the order makes a difference. Or, you can just >> remember this phrase, "multiply first, then divide." >> >> -- >> Michael T. Jones >> michael.jo...@gmail.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- Michael T. Jones michael.jo...@gmail.com -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] multiply and divide
Constructive reals in Go, anyone? :-) On 18 Aug 2017 17:50, "Michael Jones"wrote: > Here is a minor musing from something that came up yesterday. > > Sometimes we see a real number expression as simple as... > > x*y/z > > ...and knowing from basic algebra that... > > (x*y)/z == x*(y/z) > > ...we might not expect much difference between the two in our code. Alas, > computer floating point does not involve real numbers, rather it uses an > approximation of them. If you will copy https://play.golang.org/ > p/IlDxtvx7IY to your computer, build and run it, (too much CPU for the > playground) you'll find that the order makes a difference. Or, you can just > remember this phrase, "multiply first, then divide." > > -- > Michael T. Jones > michael.jo...@gmail.com > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.