Re: [go-nuts] What 5 things does Go need in 2017?
On Sun, Sep 11, 2016 at 6:44 PM, Mark Richmanwrote: > > I would definitely be interested in triage, backlog refinement, etc. Are > there product owners designated for each functional area? I could start by > making sure new issues are at least assigned to the correct PO for > prioritization. Only informally. What we see a lot of, though, are questions filed as issues. Those generally need to be redirected to https://golang.org/wiki/Questions . Also, naturally, a lot of non-bugs are filed as issues. Ian -- 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] Two Related Questions. (1) Map Concurrency (2) Making Multidimensional Arrays
*I have two Golang questions that I hope someone could help me out with.* *1) Am I misunderstanding Golang maps?* *I'm trying to translate a project from PHP to Golang for the websockets and the concurrency. * *However, I can't do this.* * var MyArray [string]string* *Instead, I have to do this.* * var MyMap map[string]string* *However, since the same array (map) would be used at least once for each call to the Golang code from the Front End, which occurs any time a user sends data to the Back End, I have been led to believe that I would have to lock and unlock the map for each use. Wouldn't that essentially break concurrency (or at least eliminate its benefits??? No other user's function could use this map until the current user's function is done with it. I'd be back to "single threaded" again (concurrently speaking). This would defeat much of the point in my switching the project from PHP to Golang. To maintain concurrency without blocking other users, one would have to avoid using maps. Arrays (maps) are central to programming. How does anyone get by in Golang without using Maps?* *For example, if I do the following.* *func MyFunc (whatever) *map[string]string *{* var MyMap map[string]string * // Do something with the map* * return MyMap* *}* *func CallingFunction (whatever) {* * MyReturnedMap := go MyFunc(whatever)* *}* *.would I have to lock and unlock the map or are two separate instances of the map declared?* *Again, am** I misunderstanding Golang maps?* *2) Also, how would one build a multidimensional array with a string index (or even a map of maps) for something like a large file directory where the number of files, folders and levels are unknown at the outset (without repeatedly using the append function that apparently uses memory on an exponential scale of 2^x)? I've figured out how to do map[string]map[string]map[string]string, but one would have to know how many levels there would be, in advance, to be able to use something like that. Also, when I've tried that, I can't put a string on any level except for the last one, since the only data type that any level other than the last one will accept is another map! What if the map turns out to be only three levels deep for one path and five levels deep for another path?** I've tried the following, which I found online, but I can't dynamically add any new folders to the directory with any kind of ease. It seems that initializing the struct is the only way to get data into the struct without declaring a new struct for every manipulation!* *(Below code from * *http://stackoverflow.com/questions/19080116/golang-tree-like-solution-for-filesystem)* package Websocket import "fmt" type File struct { Name string } type Folder struct { Namestring Files []File Folders []Folder } func main() { root := Folder{ Name: "Root", Files: []File{ {"One"}, {"Two"}, }, Folders: []Folder{ { Name: "Empty", }, }, } fmt.Printf("Root %#v\n", root) } *Given the above, how would i now add another folder to the directory tree. Among many other variations, I've tried the following.* *root.Folders[0].Name = "MyFirstFolder"* *.but nothing I have tried has worked.* *What I've been trying to do is set up an array that looks like the following.* *MyArray["Number of Sub Items"] = 6* *MyArray["Type of Sub Items"] = "Folders"* *MyArray[0] = "Folder 1"* *MyArray[1]** = "Folder 2"* *MyArray[2]** = "Folder 3"* *MyArray[3]** = "Folder 4"* *MyArray[4]** = "Folder 5"* *MyArray[6]** = "Folder 6"* *MyArray[3]**["Number of Sub Items"]** = 3* *MyArray["Type of Sub Items"] = "Folders"* *MyArray[3][0] = "Folder 1"* *MyArray[3][1]** = "Folder 2"* *MyArray[3][2]** = "Folder 3"* *Note that this problem is not exclusive to directory structure. Using directory structure is just a simple way to describe the problem I'm having.* *Alternatively**, are there any libraries that can do the above so that I don't have to "reinvent the wheel"?* -- 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] What 5 things does Go need in 2017?
Ian, I would definitely be interested in triage, backlog refinement, etc. Are there product owners designated for each functional area? I could start by making sure new issues are at least assigned to the correct PO for prioritization. With respect to packaging, I'm aware of the current effort underway. In my day job, I'm responsible for packaging -- both our internal library packages, and our customer-facing product packages. This includes the tooling around the packages, the delivery mechanism(s), web front end for administration, etc. I am admittedly a Go novice, but I think this is a relatively language-agnostic discipline. However, I know of the vendoring quirks and lack of portable libraries (i.e. dll or jar style references). If you think these are areas I could be of service, feel free to follow up with me offline if you like. Thanks, Mark http://markrichman.com mark [at] markrichman.com On Sunday, September 11, 2016 at 1:55:52 PM UTC-4, Ian Lance Taylor wrote: > > On Sun, Sep 11, 2016 at 6:43 AM, Mark Richman> wrote: > > > > I'm somewhat new to the community, and seek to understand its challenges > > better. I'm also looking for opportunities to contribute. > > > > To that end, what 5 things does Go need in 2017? > > > > For example: language features, tooling, advocacy, community, platform > > support, etc. > > Thanks for offering. There are many open issues at > https://golang.org/issue. Issue triage is an ongoing consumer of > time. > > Personally I think our biggest open issues relate to packaging, > especially managing third party packages. There is an active effort > to sort this out. > > Unfortunately helping with those does require some familiarity with > the language and the community. > > The documentation can always be improved. > > This is just off the top of my head, others may have other suggestions. > > Ian > -- 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] Re: Why a single go routine with sleep is using 100% cpu (1 core)
On 09/12/2016 03:01 AM, Sagar P. wrote: Ah, I see my mistake. Removed default to avoid a busy-loop. Thanks! Without `default` you need hot `for` and `select` at all. Just _ = <-channel: fmt.Println("Go routine has ended") os.Exit(0) would be enough. In real situations however `default` most likely be an essence. CPU load is a cost of `select` which is quite expensive operation. __ Ilya Kostarev -- 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] What 5 things does Go need in 2017?
There's also decimal128 support (first via a third-party library before inclusion into the language itself): https://github.com/golang/go/issues/12332 =) - Augusto On Sunday, September 11, 2016 at 5:01:21 PM UTC-7, Pablo Rozas-Larraondo wrote: > > Hi Mark, > > I can also suggest you to look into the open discussion that's currently > happening on how multidimensional slices should be implemented in future > versions of Go. I particularly find that area and the proposed ideas very > interesting: > https://github.com/golang/go/issues/6282 > > Cheers, > Pablo > > > > On Monday, September 12, 2016 at 3:55:52 AM UTC+10, Ian Lance Taylor wrote: >> >> On Sun, Sep 11, 2016 at 6:43 AM, Mark Richman>> wrote: >> > >> > I'm somewhat new to the community, and seek to understand its >> challenges >> > better. I'm also looking for opportunities to contribute. >> > >> > To that end, what 5 things does Go need in 2017? >> > >> > For example: language features, tooling, advocacy, community, platform >> > support, etc. >> >> Thanks for offering. There are many open issues at >> https://golang.org/issue. Issue triage is an ongoing consumer of >> time. >> >> Personally I think our biggest open issues relate to packaging, >> especially managing third party packages. There is an active effort >> to sort this out. >> >> Unfortunately helping with those does require some familiarity with >> the language and the community. >> >> The documentation can always be improved. >> >> This is just off the top of my head, others may have other suggestions. >> >> Ian >> > -- 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] Re: Why a single go routine with sleep is using 100% cpu (1 core)
Ah, I see my mistake. Removed default to avoid a busy-loop. Thanks! On Sunday, September 11, 2016 at 4:11:26 PM UTC-7, Sagar P. wrote: > > go version > go version go1.6.3 linux/amd64 > > uname -r > 3.13.0-95-generic > > Below code is using 100% cpu (1 full core) > > package main > > import ( > "fmt" > "os" > "time" > ) > > > func main() { > channel := make(chan bool, 1) > go doSomething(channel) > for { > select { > case <-channel: > fmt.Println("Go routine has ended") > os.Exit(0) > > default: > } > } > } > > func doSomething(ch chan bool) { > time.Sleep(6 * time.Millisecond) > ch <- true > } > > Please let me know if you what is happening above. > -- 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] Nil interface/pointer
On Sun, 2016-09-11 at 19:41 +1000, Kiki Sugiaman wrote: > Not exactly a solution for the faint hearted, hah! It's long, but not complicated, and in the context of Axel's comment would be placed in a helper of some variety. For those at home, it's necessary to take the address of the interface value so that it's not passed as the interface{} that reflect.ValueOf (so it retains the Fooer type indirectly via a *Fooer), the first Elem dereferences that pointer to get the original Fooer, then the second gets the concrete value in the Fooer, and finally IsNil does what it says. The only thing here that is possible a trap for novitiates is that you need to do the , Elem dance. -- 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] Re: [ANN] A terminal based search engine for bash commands, built with Go
Hey, thanks for the feedback, and code review :)) The swap files, I am definitely removing. Printing without no limit is definitely a feature I want to get done! Sorting is a very good idea, I think it will be done on the server side though. That cookbook is epic, thanks for the heads up! The moment I typed a question regarding the fruit reference which I didn't get, I realised you mean 'mango'. Hah! Cheers On Sunday, 11 September 2016 19:48:00 UTC+1, howar...@gmail.com wrote: > > Taking a quick look; you've got some Vim style .swp files in your git > repository that should be removed. > > Next, in main.go (anyone else start thinking of tropical fruits at this > point?) you use 'break Loop' when the number of lines exceeds 10, which > means one long solution can crowd out less wordy ones; maybe have an option > to print again with no limit? Then again, as you mentioned in the README, > once you've added some form of recommendation system, you can sort by that > to push the more highly recommended answers first. > > Finally, have a look at http://www.tldp.org/LDP/abs/abs-guide.pdf > > This is a BASH cookbook-style guide that has been explicitly donated to > the public domain, and should be a fertile resource for populating your > library. > > Howard > > On Sunday, September 11, 2016 at 12:52:12 PM UTC-5, johnny-john wrote: >> >> Hi all! >> >> Just thought about dropping this link here, the codebase is VERY small, >> so if you are a newbie looking for a project to get into, have a look: >> https://github.com/crufter/borg >> >> Cheers >> > -- 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] Another divide by zero (float) question
On Sun, Sep 11, 2016 at 11:40 AM,wrote: > https://play.golang.org/p/tLSyUw1Ojq > > This operation is caught by the compiler > > a:=float32(1) / float32(0) > > > ok This has been asked before - but not with a satisfactory answer afaict > > The spec says ( https://golang.org/ref/spec#Arithmetic_operators ) The > result of a floating-point or complex division by zero is not specified > beyond the IEEE-754 standard; .. > > But the IEEE754 standard does specify behaviour, and the divide by zero has > a valid, defined result. > > I get the compiler is trying to catch some sort of error here - but I'm not > convinced it's ever helpful, and contradicts fully supporting the standard. > > Does anyone have a good defence of this compiler warning for floats? Personally I think it was probably a mistake. The relevant part of the spec is https://golang.org/ref/spec#Constant_expressions where it says "The divisor of a constant division or remainder operation must not be zero." Ian -- 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] Another divide by zero (float) question
https://play.golang.org/p/tLSyUw1Ojq This operation is caught by the compiler a:=float32(1) / float32(0) ok This has been asked before - but not with a satisfactory answer afaict The spec says ( https://golang.org/ref/spec#Arithmetic_operators ) *The result of a floating-point or complex division by zero is not specified beyond the IEEE-754 standard; ..* But the IEEE754 standard* does specify behaviour*, and the divide by zero has a valid, defined result. I get the compiler is trying to catch some sort of error here - but I'm not convinced it's ever helpful, and contradicts fully supporting the standard. Does anyone have a good defence of this compiler warning for floats? -- 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] What 5 things does Go need in 2017?
On Sun, Sep 11, 2016 at 6:43 AM, Mark Richmanwrote: > > I'm somewhat new to the community, and seek to understand its challenges > better. I'm also looking for opportunities to contribute. > > To that end, what 5 things does Go need in 2017? > > For example: language features, tooling, advocacy, community, platform > support, etc. Thanks for offering. There are many open issues at https://golang.org/issue. Issue triage is an ongoing consumer of time. Personally I think our biggest open issues relate to packaging, especially managing third party packages. There is an active effort to sort this out. Unfortunately helping with those does require some familiarity with the language and the community. The documentation can always be improved. This is just off the top of my head, others may have other suggestions. Ian -- 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] [ANN] A terminal based search engine for bash commands, built with Go
Hi all! Just thought about dropping this link here, the codebase is VERY small, so if you are a newbie looking for a project to get into, have a look: https://github.com/crufter/borg Cheers -- 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] how to resolve the warning about composite literal uses unkeyed fields .
Thank you very much 在 2016年8月24日星期三 UTC+8下午2:07:52,Deshi Xiao写道: > > Thanks Matt > > 2016-08-23 9:56 GMT+08:00 Matt Harden: > >> cluster.ImageFilterOptions has an embedded field of type >> types.ImageListOptions. When fields are embedded, the field name is set to >> the type. So you can write: >> >> groupImages := make(map[string]apitypes.Image) >> opts := cluster.ImageFilterOptions{ >> ImageListOptions: apitypes.ImageListOptions{ >> All: boolValue(r, "all"), >> MatchName: r.FormValue("filter"), >> Filters: filters, >> }, >> } >> >> >> On Mon, Aug 22, 2016 at 6:35 PM tommy xiao > > wrote: >> >>> the go vet always report composite literal uses unkeyed fields warning, >>> >>> $ go vet `go list ./...|grep -v /vendor/` >>> api/handlers.go:189: github.com/docker/swarm/cluster.ImageFilterOptions >>> composite literal uses unkeyed fields >>> exit status 1 >>> scheduler/filter/dependency_test.go:60: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:69: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:78: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:87: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:96: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:105: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:160: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:169: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:178: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:187: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:241: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> scheduler/filter/dependency_test.go:252: >>> github.com/docker/swarm/cluster.ContainerConfig composite literal uses >>> unkeyed fields >>> exit status 1 >>> >>> >>> the source code is : >>> >>> groupImages := make(map[string]apitypes.Image) >>> opts := cluster.ImageFilterOptions{ >>> apitypes.ImageListOptions{ // <--- here >>> All: boolValue(r, "all"), >>> MatchName: r.FormValue("filter"), >>> Filters: filters, >>> }, >>> } >>> >>> i found the annoy warning and the fix way is not cover this case. anyone >>> can clarify which way can elegant to remove it. anyone can do me a favor. >>> thanks a lot. >>> >>> -- >>> Deshi Xiao >>> Twitter: xds2000 >>> E-mail: xiaods(AT)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...@googlegroups.com . >>> For more options, visit https://groups.google.com/d/optout. >>> >> > > > -- > Deshi Xiao > Twitter: xds2000 > E-mail: xiaods(AT)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] Re: Can't understand untyped constant behavior
Il giorno domenica 11 settembre 2016 13:30:40 UTC+2, Uvelichitel ha scritto: > > > On 09/10/2016 09:18 PM, Manlio Perillo wrote: > > Il giorno giovedì 8 settembre 2016 17:31:55 UTC+2, Uvelichitel ha scritto: >> >> >> func main() { >> const x, y = 5, 3 >> var f float32 = x / y >> fmt.Println(f) >> } >> >> > In your case the default type of x and y are integer constants. > > > Manlio > > Hi Manio. > Things are not so simple, say > const x, y = int 5, 3 / /explicitly > This statement is incorrect. You probably mean: > var f float32 = x / y > just doesn't compile with an error "cannot use x / y (type int) as type > float32 in assignment" > __ > > Ilya Kostarev > -- 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] Re: Assigning +Inf to a float32 ..
ok thanks - that seems to be them all I think the library would benefit from more 'obvious' , built in constant, or single parameterless function to generate these - more commonly as values to test output against, rather than inputs. I'll put in that request and see if it gets picked up. Also curious as why the implementation is as math.NaN() rather than just math.NaN (function/method not constant). It doesn't seem to help with a potential interfaces. -- 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] Re: Can't understand untyped constant behavior
On Sun, Sep 11, 2016 at 4:33 AM, Ilya Kostarevwrote: > > On 09/10/2016 09:18 PM, Manlio Perillo wrote: > > Il giorno giovedì 8 settembre 2016 17:31:55 UTC+2, Uvelichitel ha scritto: >> >> >> func main() { >> const x, y = 5, 3 >> var f float32 = x / y >> fmt.Println(f) >> } >> > > In your case the default type of x and y are integer constants. > > > Manlio > > Hi Manio. > Things are not so simple, say > const x, y = int 5, 3 / /explicitly > var f float32 = x / y > just doesn't compile with an error "cannot use x / y (type int) as type > float32 in assignment" That example doesn't build. But I think that all your questions are answered at https://blog.golang.org/constants . Ian -- 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] Re: Can't understand untyped constant behavior
On 09/10/2016 09:18 PM, Manlio Perillo wrote: Il giorno giovedì 8 settembre 2016 17:31:55 UTC+2, Uvelichitel ha scritto: func main() { const x, y = 5, 3 var f float32 = x / y fmt.Println(f) } In your case the default type of x and y are integer constants. Manlio Hi Manio. Things are not so simple, say const x, y = int 5, 3 / /explicitly var f float32 = x / y just doesn't compile with an error "cannot use x / y (type int) as type float32 in assignment" __ Ilya Kostarev -- 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] Nil interface/pointer
Thanks, Dan. Not exactly a solution for the faint hearted, hah! -- 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] Assigning +Inf to a float32 ..
Ignore. math.NaN() is there! J John John Souvestre - New Orleans LA From: John Souvestre [mailto:j...@souvestre.com] Sent: 2016 September 11, Sun 02:39 To: 'golang-nuts' Subject: RE: [go-nuts] Assigning +Inf to a float32 .. This does beg the question: Why is there no math.NaN() function? John John Souvestre - New Orleans LA From: golang-nuts@googlegroups.com [mailto:golang-nuts@googlegroups.com] On Behalf Of Dave Cheney Sent: 2016 September 11, Sun 01:00 To: golang-nuts Cc: xiiop...@gmail.com Subject: Re: [go-nuts] Assigning +Inf to a float32 .. https://play.golang.org/p/RthMnILvkP func main() { inf := float32(math.Inf(+1)) fmt.Println(inf) } -- 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] Assigning +Inf to a float32 ..
This does beg the question: Why is there no math.NaN() function? John John Souvestre - New Orleans LA From: golang-nuts@googlegroups.com [mailto:golang-nuts@googlegroups.com] On Behalf Of Dave Cheney Sent: 2016 September 11, Sun 01:00 To: golang-nuts Cc: xiiop...@gmail.com Subject: Re: [go-nuts] Assigning +Inf to a float32 .. https://play.golang.org/p/RthMnILvkP func main() { inf := float32(math.Inf(+1)) fmt.Println(inf) } -- 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] Assigning +Inf to a float32 ..
https://play.golang.org/p/RthMnILvkP func main() { inf := float32(math.Inf(+1)) fmt.Println(inf) } On Sunday, 11 September 2016 15:58:04 UTC+10, bradfitz wrote: > > Not beautiful, but... > > https://play.golang.org/p/WWEEJN8LcF > > func main() { > i32 := math.Float32frombits(0x7F80) > fmt.Printf("%T = %v", i32, i32) > } > > // float32 = +Inf > > > > On Sat, Sep 10, 2016 at 6:55 PM,wrote: > >> ok I want to assign +Inf as a float32. >> >> Currently I work around like this : >> >> package main >> >> import ( >> "fmt" >> ) >> >> func main() { >> var a,b,c float32 >> a=1 >> b=0 >> //c=float32(1.0)/float32(0.0) //can't do it >> //c=+Inf //doesn't work - not a keyword >> c=a/b //kludge >> fmt.Println (a,b,c) >> } >> >> >> Couldn't find a way to do this - not even in the math package .. (I see >> that +Inf is in the math package but it is not exported) ie lines 8-10 in >> math/bits.go >> >> Am I missing something obvious.? >> >> In https://golang.org/ref/spec#Numeric_types it states "*float32 the >> set of all IEEE-754 32-bit floating-point numbers" * >> >> If not is a request that +Inf etc be exported from math reasonable ? >> (also signed zeros etc) >> >> -- >> 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...@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.