[go-nuts] why math.Pow gives different results depending on exp type

2024-04-19 Thread DrGo
``` package main import ( "fmt" "math" ) func main() { fmt.Printf("%g\n", 1-(math.Pow(0.6, 1/13))) //result=0 fmt.Printf("%g\n", 1-(math.Pow(0.6, 1.0/13))) // result=0.038532272011602364 } ``` https://go.dev/play/p/oIKGb_uyLb3 -- You received this message because you are subscribed to the

Re: [go-nuts] Re: Error handling

2023-08-04 Thread DrGo
Notararigo wrote: > > > On Thu, Aug 3, 2023, 23:45 DrGo wrote: > >> @Miguel Angel Rivera Notararigo >> >> Thanks for taking the time to write... >> >> In my proposal, people are free to add as much context as they want... >> > > Yeah I know, I

Re: [go-nuts] Re: Error handling

2023-08-03 Thread DrGo
use recover somewhere } Which is a bad practice, but at least we (the people who like how Go handle errors) can still handle our errors without any language change. On Tue, Aug 1, 2023, 13:06 DrGo wrote: Thanks. The keystroke saving is not the motivation. The aim is to reduce the code reade

Re: [go-nuts] Error handling

2023-08-03 Thread DrGo
wrote: > Dnia 2023-07-29, o godz. 22:57:15 > DrGo napisał(a): > > > This involves introducing a new keyword "orelse" that is a syntactic > sugar for an "if err!=nil" block. > > You can implement it as a snippet under any editor in use today. > >

Re: [go-nuts] Error handling

2023-08-03 Thread DrGo
to a proposal: >> which of the two perspectives does the proposal tackle? I'm under the >> assumption that it might have been #2 in most of the proposals. The often >> vivid negative responses should then be classified as belonging to #1 >> and/or #2. If the proposal is about #2, th

Re: [go-nuts] Error handling

2023-08-03 Thread DrGo
ng to #1 > and/or #2. If the proposal is about #2, then #1 proponents don't > contribute, but simply make life hard for the #2 customers of the Go > language. Same for the opposite combination. > > On Wednesday, August 2, 2023 at 6:11:01 PM UTC+2 DrGo wrote: > >> Fair enough … I

Re: [go-nuts] Error handling

2023-08-02 Thread DrGo
already has its share of surprises you have to learn. > > On Tuesday, 1 August 2023 at 22:41:38 UTC+1 DrGo wrote: > >> Yes. Go is no longer the simple language it was. I suspect because of >> internal pressures within Google as evidenced by multiple innovations that >> seem

Re: [go-nuts] Error handling

2023-08-01 Thread DrGo
any other name? >> >> I disagree that this makes the job of linters any easier than it is >> today. For example, if you'd written >> >> ... >>err = io.Copy(w, r) >> err = w.Close() orelse return err >> } >> >> then you'd still nee

[go-nuts] Re: Error handling

2023-08-01 Thread DrGo
Fair enough. But many would prefer shorter functions if there is no loss to explicitness or clarity. On Tuesday, August 1, 2023 at 11:10:30 AM UTC-6 Stephen Illingworth wrote: > On Tuesday, 1 August 2023 at 18:06:25 UTC+1 DrGo wrote: > > Compare the following; which one would y

Re: [go-nuts] Re: Error handling

2023-08-01 Thread DrGo
Thanks Jan Indeed the majority can be wrong but in this case the OLD smart minority too wanted a way to improve things. This approach was in fact dictated by their requirements On Tuesday, August 1, 2023 at 2:10:57 AM UTC-6 Jan Mercl wrote: > On Tue, Aug 1, 2023 at 1:47 AM DrGo wr

Re: [go-nuts] Re: Error handling

2023-08-01 Thread DrGo
k this is a direct design > goal. If the keyword vs lines of code/tokenspace is worth it, so be it. > Who am I to say. If we are truely circling on a way to handle errors in a > chain, then the chain aspect is at least as important as any one line, and > up to this point has

[go-nuts] Re: Error handling

2023-08-01 Thread DrGo
err := myFunction() >if err != nill { >return rest, err >} > } > ``` > > Op maandag 31 juli 2023 om 04:32:01 UTC+2 schreef DrGo: > >> Another possibility Jeremy is that the orelse block is executed if any of >> the returned error values

Re: [go-nuts] Re: Error handling

2023-07-31 Thread DrGo
). Having something which fits within the design > of the language, making it a developer centric language, would seem to > fight with any one-line-template approach. > > tim > > > > > > The test and the handle all fit on one line. I dont think having a > si

[go-nuts] Re: Error handling

2023-07-31 Thread DrGo
t 'orelse' could be done with > the existing 'else' keyword, i.e., > > ``` > result, err := someCall() else rest, err > ``` > Anyway, I really do hope the long-winded error syntax gets solved somehow! > > On Monday, July 31, 2023 at 5:41:49 AM UTC+1 DrGo wrote: > &g

[go-nuts] Re: Error handling

2023-07-30 Thread DrGo
the third example from the paper, > which does (proper) error annotation and cleanup. Thanks. > On Sunday, July 30, 2023 at 8:57:15 AM UTC+3 DrGo wrote: > >> I looked at the long list of proposals to improve error handling in go >> but I have not seen the one I am describing belo

[go-nuts] Re: Error handling

2023-07-30 Thread DrGo
l > { return foo }" ?? > > On Sunday, 30 July 2023 at 10:20:12 UTC+1 Brian Candler wrote: > >> On Sunday, 30 July 2023 at 09:40:25 UTC+1 DrGo wrote: >> >> orelse must return an error (ie satisfies the error interface); the >> specific type and variable name do no

[go-nuts] Re: Error handling

2023-07-30 Thread DrGo
thanks for the link. unlike the onErr approach, my proposal does not treat create special-status identifier; the orelse block is like any other else block On Sunday, July 30, 2023 at 1:31:09 AM UTC-6 Brian Candler wrote: On Sunday, 30 July 2023 at 06:57:15 UTC+1 DrGo wrote: I looked

[go-nuts] Re: Error handling

2023-07-30 Thread DrGo
= io.Copy(w, r) err = w.Close() orelse return err } then you'd still need to detect "value assigned but not used" in the linter (assuming it doesn't become *compulsory* to use "orelse" on any assignment to a variable called "err") On Sunday, 30 July 2023 at 06:

[go-nuts] Error handling

2023-07-29 Thread DrGo
I looked at the long list of proposals to improve error handling in go but I have not seen the one I am describing below. If I missed a similar , can you pls direct me to where I can find it. If not what do you think of this approach. This involves introducing a new keyword "orelse" that is a

[go-nuts] Re: Differences between go1.16 and go1.15 ?

2021-02-20 Thread DrGo
Dear Lorenzo, Here’s a link to an old but still relevant tutorial on benchmarking Go programs https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go Happy benchmarking On Saturday, February 20, 2021 at 11:19:40 AM UTC-6 TiT8 wrote: > > Thank you Volker. > > I want to say that I was

[go-nuts] Re: program times out on go playground and runs but with race on mac running go1.16beta

2021-01-20 Thread DrGo
Thanks a million Totally missed that first err was not limited to the scope of the case or the go routine. On Wednesday, January 20, 2021 at 6:02:29 PM UTC-6 Carla Pfaff wrote: > result <- Event{event, err} > > reads the `err` variable in one goroutine, and > > err = watcher.Add(dir) >

[go-nuts] program times out on go playground and runs but with race on mac running go1.16beta

2021-01-20 Thread DrGo
if I run this program in the playground, I get: timeout running program Program exited: status 1 https://play.golang.org/p/5cDYasXtl_n If I run it on my macos Catalina machine with go 1.16 beta I get a data race warning ``` WARNING: DATA RACE Read at 0x00c00011a2a0 by goroutine 10:

[go-nuts] Re: confusing compile error message after renaming module

2021-01-17 Thread DrGo
Of course, once you post about a problem, you immediately figure it out. I forgot to update the go files in the package folder to reflect the name change package liverserver--> package gols fixes the issue. On Sunday, January 17, 2021 at 10:14:36 PM UTC-6 DrGo wrote: > Wondering if s

[go-nuts] confusing compile error message after renaming module

2021-01-17 Thread DrGo
Wondering if someone knows what is going on here: I renamed a module in go.mod from liverserver [sic] to gols and imported it in main.go in a "cmd" subdir. Now I am getting this error when I compile main.go: ./main.go:8:2: imported and not used: "github.com/drgo/gols" as l

Re: [go-nuts] Re: [generics] Feedback on optional type keyword experiment

2020-07-25 Thread DrGo
I too think that T any is more readable than the overloaded type in type T especially if it means that I won’t have to remember when it’s Ok to drop type and when it’s not On Saturday, July 25, 2020 at 4:47:17 PM UTC-5 Denis Cheremisov wrote: > Great catch! I would say I really like it! > >

[go-nuts] Unmarshalling ordered nested dynamic xml

2020-03-29 Thread DrGo
Hi, wondering how to unmarshall the xml below (also available here https://play.golang.org/p/QtZwKmrn8HM) into a tree. The challenge is that each element can nest 0 or more *ordered* child elements which can be of different types (eg text, group, choose, macro etc). I tried unmarshalling into

Re: [go-nuts] setting up a hardened https server in go 1.13

2020-02-21 Thread DrGo
> > On 2020-02-21 16:13, Amnon Baron Cohen wrote: >> > >> Default connection limits suggest it isn't production ready by default >> and so is >> the main reason...so define properly hardened, but also. > > > For an average schmuck like me, "hardened" means that I am not criminally

[go-nuts] setting up a hardened https server in go 1.13

2020-02-20 Thread DrGo
https://blog.gopheracademy.com/advent-2016/exposing-go-on-the-internet/ I found this article very helpful in setting up a hardened https server. But It dates back to 2016 and go 1.8. Are there more up-to-date recommendations for go 1.13? Thanks, -- You received this message because you are

[go-nuts] running godoc in a dir outside gopath

2019-07-28 Thread DrGo
Hello, Wondering what I am doing wrong. Using go13.beta1 (Darwin), I am running a freshly downloaded godoc in a dir that includes several of my own packages like this godoc -http=localhost:6060 -goroot ~/local/git/ But on the browser, godoc is simply serving a list of all files in the dir

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-05-07 Thread DrGo
I suggest that we first solve less controversial issues like the Israeli–Palestinian conflict. -- 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

Re: [go-nuts] efficient random float32 number generator?

2019-03-03 Thread DrGo
For future reference: After trying different solutions (some are described in the above posts), the most performant solution was based on Michael Jones' pcg package ( https://github.com/MichaelTJones/pcg) with a tweaked Bound() function (to use an algorithm similar to Go's std lib). Using Go

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread DrGo
nice speedup using https://github.com/MichaelTJones/pcg <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FMichaelTJones%2Fpcg=D=1=AFQjCNGPmR0DiOobBhs9QKIFJ5T92T6p1A> ## using stdlb math/rand (Go 1.11.5) pkg: github.com/drgo/abm/rng BenchmarkScalingFreqDistributionSampler/n-level

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread DrGo
Thanks everyone for helpful feedback, What do people think about the approach explained here http://iquilezles.org/www/articles/sfrand/sfrand.htm? Any possible disadvantages in a Go implementation? -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread DrGo
Thanks Ian, The std lib float32 is slow for my purpose. In my benchmarking it is actually slower than the float64. But I don’t even need float16 precision. I am working on implementing othe alias method for sampling from a fixed freq dist with possibly thousands of arbitrary values. So the rng

[go-nuts] Re: sharing types between interface and implementation

2019-02-21 Thread DrGo
what worked for me in a largish project is using an internal package (named "types") to host types used in more than package. On Thursday, February 21, 2019 at 3:30:08 PM UTC-6, Manlio Perillo wrote: > > Hi. > > I'm implementing a generic (and very simple) interface for key-value > databases,

[go-nuts] error building go from source

2018-11-01 Thread DrGo
wondering if anyone ran into this issue trying to build go1.11.1 or tip *➜ **src* *git:(**26957168c4**) **✗* ./all.bash Building Go cmd/dist using /usr/local/Cellar/go/1.11.1/libexec. Building Go toolchain1 using /usr/local/Cellar/go/1.11.1/libexec. go: warning: "bootstrap/cmd/..."

[go-nuts] Go 2 error handling non-proposal

2018-10-29 Thread DrGo
What I like about error handling in Go is that errors are just values. Like any other values, they can be transparently stored, aggregated, passed around and used, among other things, to explicitly change program flow. That is why I am on the whole satisfied by Go 1's approach and a bit

[go-nuts] Computer Programmer - Information Technologist 4 (c, c++, Go)

2018-09-10 Thread DrGo
*Job Description :* Computer Programmer - Information Technologist 4 (AESES) New Grant-Funded Project Full-Time 35.00 hours/week Monday to Friday 8:30-4:30 Salary Range: ($65,538.20 - $87,669.40 per annum). For more information, please contact: Andrea Toyne 753 McDermot Ave

Re: [go-nuts] Re: looking for a flexible file path resolver

2018-08-06 Thread DrGo
, some are discussed here https://github.com/golang/go/issues/17084 and here <https://www.baeldung.com/java-path> On Monday, August 6, 2018 at 9:46:39 AM UTC-5, Marvin Renich wrote: > > * DrGo > [180806 02:00]: > > Thanks, > > filepath.Abs does some of what I want,

[go-nuts] looking for a flexible file path resolver

2018-08-05 Thread DrGo
In many applications, I need to resolve an arbitrary file name that a user provided to a valid file-system path that can be used to open, create or append to a file. I think I now have written 4 funcs to achieve one or another of these objectives, but none that is flexible enough and robust

[go-nuts] Silent errors during template execution

2018-03-24 Thread DrGo
Hello, I have an app that uses Go's standard template package. The app reads an xml file and passes the info to a template (snippet shown below) including a slice of structs that the template can range over. eg {{- range $source:= $grant.SubSection "Funding Sources" }} Although the

Re: [go-nuts] Re: Experience Report building OCR in Go

2018-01-22 Thread DrGo
Thanks for your informative report. I fully agree with you re the zero value of maps. A read-only empty is useless. -- 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

Re: [go-nuts] An efficient algorithm to write binary data

2017-10-29 Thread DrGo
Michael, here is the cleaner (thanks to your suggestion) current version: //writeData loops over the field vectors and write their binary representation to an io.Writer func (sf *File) writeData(w io.Writer) error { if sf.NoObs == 0 { return nil } if len(sf.fields) == 0 {

[go-nuts] An efficient algorithm to write binary data

2017-10-29 Thread DrGo
Thanks Tamas, I agree re float32bits. I think the compiler will inline it. Right? Re binary.put*, I am essentially inlining their implementation and avoiding unnecessary use of reflection for serializing the floats. I am not sure I understand your point re the type switch, can you provide an

[go-nuts] An efficient algorithm to write binary data

2017-10-29 Thread DrGo
Thanks, I agree re float32bits. I think the compiler will inline it. Right? Re binary.put*, I am essentially inlining their implementation and avoiding unnecessary use of reflection for serializing the floats. I am not sure I understand your point re the type switch, can you provide an

[go-nuts] An efficient algorithm to write binary data

2017-10-27 Thread DrGo
Hello, I am looking for help reviewing the function below. I need to generate millions of large files in a specific binary format. I do not care about portability (only used on Little Endian machines). The file format writes the data in row order, so need to loop over slices of different types

[go-nuts] Create a file and control whether to overwrite or not

2017-09-17 Thread DrGo
Hello, The default behaviour of os.Create is to truncate the file if already exists. I wrote the code below to control whether the file should be overwritten or not (possibly based on user wishes). Seems to work on MacOS. Do you think this code will work on Windows and Linux? Do you see any

[go-nuts] Today I discovered another std lib gem: strings.NewReplacer

2017-09-09 Thread DrGo
I needed to replace a specially coded tokens with their unicode representations. strings.NewReplacer made it clean and easy. first, you pass to strings.NewReplacer a string array literal made up of old, new string pairs, like so var logicalReplacer = strings.NewReplacer( "%and", `∧`,

[go-nuts] Today, I discovered a std library gem: strings.NewReplacer

2017-09-09 Thread DrGo
I needed to replace a specially coded tokens with their unicode representations. strings.NewReplacer made it clean and easy. first, you pass to strings.NewReplacer a string array literal made up of old, new string pairs, like so var logicalReplacer = strings.NewReplacer( "%and", `∧`,

[go-nuts] const struct

2017-09-07 Thread DrGo
Sorry if this was asked before, but I could not find any relevant posts. Any reason why this struct literal (made up of fields that can be declared const) is not allowed? const UnknownPos = scanner.Position{"", -1, -1, -1} error: const initializer scanner.Position literal is not a constant.

[go-nuts] append() gotcha!

2017-08-15 Thread DrGo
Hello, The following compiles as well as evades scrutiny by go Vet (and many a human reviewer) resulting in perplexing bugs. What purpose calling append() with only one argument serves? Shouldn't it be banned? ``` var byteArray= []byte{'A', 'B',} func main() { buf:=[]byte {'C'} buf =

[go-nuts] Introduction to Gonum: Numerical libraries for Go

2017-07-28 Thread DrGo
Very nice, 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

[go-nuts] struct initialization

2017-03-09 Thread DrGo
Given this declaration type globalOptions struct { ... ccv *ccvxml.CCV funcMap template.FuncMap } Why this does not compile //Initialize template functions func newGlobalOptions() *globalOptions { g := globalOptions{ ccv: ccvxml.New(),

[go-nuts] Anatomy of a go web application

2016-12-04 Thread DrGo
Thanks Tim, Very nice overview of the mechanics of a web app. -- 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

[go-nuts] Go vs. the rest

2016-11-08 Thread DrGo
https://arxiv.org/pdf/1409.0252.pdf A nice analysis showing that Go gets the balance of performance vs robustness right. Some aspects of the analysis are naive, like measuring productivity by numbers of lines. And this is using Go 1.3!! -- You received this message because you are subscribed

Re: [go-nuts] file or folder encryption tool

2016-09-19 Thread DrGo
Thanks Nick, This looks promising! -- 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

Re: [go-nuts] Go performance in regexdna

2016-09-01 Thread DrGo
Thanks Ian, Very helpful -- 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

[go-nuts] Go performance in regexdna

2016-09-01 Thread DrGo
What is the reason for Go particularly poor performance in regexdna as shown here? https://benchmarksgame.alioth.debian.org/u64q/performance.php?test=regexdna Cheers -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Re: text/scanner: scan() vs peek()

2016-08-25 Thread DrGo
Thanks Sam, I managed without a token_peek(). It just leads to more verbose code with calls to scan() and switches everywhere. On Thursday, August 25, 2016 at 10:52:54 PM UTC+1, Sam Whited wrote: > > On Thu, Aug 25, 2016 at 2:09 PM, DrGo <salah@gmail.com > > wrote: > &g

[go-nuts] text/scanner: scan() vs peek()

2016-08-25 Thread DrGo
Hello, Perhaps I am misunderstanding the purpose or do not know how to optimally use this package, but the way I see it scanner.peek() is not doing what I expect it to do: return the next non-whitespace token (e.g., scanner.Ident, scanner.Int etc) without advancing the scanner. Instead it

[go-nuts] World Famous Gopher Hole Museum: Alberta Canada

2016-07-29 Thread DrGo
Gophers in the news: http://www.cbc.ca/shortdocs/shorts/world-famous-gopher https://www.youtube.com/watch?v=QGT8XLrYnio -- 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