Re: [go-nuts] time.ParseDuration does not accept scientific notation

2024-04-26 Thread Scott Pakin
On Friday, April 26, 2024 at 6:08:02 PM UTC-6 Ian Lance Taylor wrote: The first step would be to open a proposal for this change. See https://github.com/golang/proposal#readme. Thanks. Done: proposal: time: allow scientific notation in ParseDuration

[go-nuts] time.ParseDuration does not accept scientific notation

2024-04-26 Thread Scott Pakin
While parsing output from some third-party program, I discovered that time.ParseDuration does not accept inputs expressed in scientific notation even though strconv.ParseFloat does accept such inputs. Here’s an play

[go-nuts] godoc formatting of example test

2023-01-03 Thread Scott Pakin
It seems godoc doesn't honor much formatting when rendering function comments for Example functions. In particular, it rewraps text that I consider preformatted. For example, // This is an example: // //foo // bar // baz // // Why does godoc wrap those lines in examples? func Exam

Re: [go-nuts] Implementation of image.NRGBA64

2021-09-28 Thread Scott Pakin
M UTC-6 Nigel Tao wrote: > On Tue, Sep 28, 2021 at 3:53 AM Scott Pakin wrote: > >> I'm curious: Why does image.NRGBA64 define Pix as a []uint8 and >> perpetually pack pairs of uint8 values into a uint16? Wouldn't it have >> been easier and faster to defi

[go-nuts] Implementation of image.NRGBA64

2021-09-27 Thread Scott Pakin
I'm curious: Why does image.NRGBA64 define Pix as a []uint8 and perpetually pack pairs of uint8 values into a uint16? Wouldn't it have been easier and faster to define Pix as a []uint16 and Stride to be a stride in uint16s rather than uint8s? — Scott -- You received this message because you

[go-nuts] Re: Query on using Closures

2021-06-06 Thread Scott Pakin
Just a guess: You may need to make a local copy of index inside your loop because index gets overwritten each iteration. On Sunday, June 6, 2021 at 12:45:01 PM UTC-6 Suveetha Kamatchi wrote: > Hi team > I am a newbie to golang. > I am writing a code that does transactions in postgres. > The li

Re: [go-nuts] Operator precedence

2021-06-06 Thread Scott Pakin
Axel and Keith: Thanks for responding. I'm glad it sounds like I'm reading the spec correctly—and that Go shouldn't do anything sneaky with evaluation order. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and st

Re: [go-nuts] Operator precedence

2021-06-06 Thread Scott Pakin
Alex and Keith: Thanks for responding. I'm glad it sounds like I'm reading the spec correctly—and that Go shouldn't do anything sneaky with evaluation order. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and st

[go-nuts] Operator precedence

2021-05-29 Thread Scott Pakin
When the Operator precedence section of the language specification says that "Binary operators of the same precedence associate from left to right. For instance, x / y * z is the same as (x / y) * z", does this imply that the language guarantees

[go-nuts] Re: Compiler treatment of infinite loops

2021-03-05 Thread Scott Pakin
On Friday, March 5, 2021 at 8:20:36 AM UTC-7 Brian Candler wrote: > There is a flip side to that: if you add the return statements, then > ForLoop1() gives an error due to unreachable code! > https://play.golang.org/p/0bajnJWTz7U > > So you can't win either way. I think this implies that if the

[go-nuts] Compiler treatment of infinite loops

2021-03-04 Thread Scott Pakin
The Go compiler (I'm using go1.16 linux/amd64) correctly infers that function with an infinite for { … } loop that conditionally returns a value from within the loop does not also need to return a value at the end of the function: - https://play.golang.org/p/07ZjFx2uJlx However, changing th

[go-nuts] [ANN] New Go package: xmorph

2021-01-18 Thread Scott Pakin
It's perhaps a bit of a niche tool, but I just released *xmorph*, a package for warping and morphing images. The code is available from https://github.com/spakin/xmorph (If nothing else, you can see there my crude attempt at morphing the cartoon Go gopher into the corresponding plush toy.) Th

Re: [go-nuts] It is said that future Macs will use ARM, is golang ready for this move ?

2020-06-10 Thread Scott Pakin
On Wednesday, June 10, 2020 at 1:24:24 PM UTC-6, David Riley wrote: > > This is certainly pedantry, but it's worth noting that the VAX to Alpha > translation in VMS wasn't dynamic recompilation, but static. There are > almost certainly similar examples; I'm not familiar enough with NT history >

Re: [go-nuts] Why isn't there "number plus" postfix syntax for more than or equal?

2020-04-24 Thread Scott Pakin
On Friday, April 24, 2020 at 8:44:46 AM UTC-6, Michael Jones wrote: > > That feels clearer to me. Both concepts are now made explicit. The > language Pascal has ranges and a membership clause. ADA also embraced some > of it. We could imagine: > > a in 99.. > a in 99..123 > > The “in” part feels i

[go-nuts] Re: HSV image format

2020-04-01 Thread Scott Pakin
On Sunday, March 29, 2020 at 11:30:02 AM UTC-6, Scott Pakin wrote: > > Does anyone know of a package that provides an image.Image > <https://golang.org/pkg/image/#Image> with an HSV color model > <https://golang.org/pkg/image/color/#Model>? I've found lots of &

[go-nuts] HSV image format

2020-03-29 Thread Scott Pakin
Does anyone know of a package that provides an image.Image with an HSV color model ? I've found lots of functions that convert color models but not a package that puts it all together into an Image interface. If

[go-nuts] Re: Writing bitmap data to a canvas with WebAssembly

2020-03-22 Thread Scott Pakin
I figure I ought to follow up with some results. First, I got the suggested approach of local render + js.CopyBytesToJS + update canvas from image to work, so thanks, Agniva and Howard! Second, for the benefit of future readers of this thread

[go-nuts] Re: Writing bitmap data to a canvas with WebAssembly

2020-03-12 Thread Scott Pakin
On Thursday, March 12, 2020 at 1:14:43 PM UTC-6, howar...@gmail.com wrote: > > If the was off-screen or hidden, couldn't you still reference it to > get the data into the canvas like: > var img = document.getElementById('targetImg'); > ctx.drawImage(img, 10, 10); > > Might not be the most eff

[go-nuts] Re: Writing bitmap data to a canvas with WebAssembly

2020-03-12 Thread Scott Pakin
On Thursday, March 12, 2020 at 11:35:30 AM UTC-6, Agniva De Sarker wrote: > > There is no base64 conversion now anywhere. If you read the code below, > you'll see I use > > dst := js.Global().Get("Uint8Array").New(len(s.outBuf.Bytes())) > n := js.CopyBytesToJS(dst, s.outBuf.Bytes()) > s.console.C

[go-nuts] Re: Writing bitmap data to a canvas with WebAssembly

2020-03-11 Thread Scott Pakin
Thanks for the links and summaries. I had actually seen a few of those pages before. The plasma demonstration at least provides some empirical evidence that as hacky as it is to convert binary→base-64 ASCII→binary for every frame update, the actual performance isn't too terrible. On Wednesday

[go-nuts] Writing bitmap data to a canvas with WebAssembly

2020-03-11 Thread Scott Pakin
I'm new to WebAssembly and am trying to get Go to generate a bitmapped image to display in the Web browser. Here's what I've come up with so far: func DrawPicture(this js.Value, args []js.Value) interface{} { // Create a canvas on the Web page. const width = 256 const hei

Re: [go-nuts] Panicking in public API ?

2020-01-09 Thread Scott Pakin
On Tuesday, January 7, 2020 at 12:47:28 AM UTC-7, Axel Wagner wrote: > > Thus, panics are the right tool to use when reporting an issue that > requires programmer attention and errors are the right tool when reporting > an issue that requires user-attention (or, of course, can be handled > progr

[go-nuts] Re: ? How restrict usage of packages ?

2019-11-25 Thread Scott Pakin
On Monday, November 25, 2019 at 9:55:55 AM UTC-7, Daniel Norte Moraes wrote: > >I Want create and permite my users to create go lang programs mostly > with full capabilities from > golang itself, but with some direct capabilities as net and filesystem > striped from direct accesss; mostly >

[go-nuts] [ANN] Go Server Pages

2019-10-08 Thread Scott Pakin
I'm excited to announce the initial release of Go Server Pages Go Server Pages is an Apache module that lets you embed Go code within a Web page. The Go code gets executed dynamically server-side. Here's a quick example: Test of Go Server Pages You should https://gos

[go-nuts] Writing my first Go module

2019-06-20 Thread Scott Pakin
I've written a package to which I'm about to make an incompatible API change. I figured this would be a good opportunity to learn about Go modules. I think I understand the basics, but there are a few details I'm confused about: First, on the repository side, all I need to do is include go.mo

[go-nuts] Embedded files with WebAssembly

2019-01-08 Thread Scott Pakin
I just started playing with WebAssembly, and I realize I don't know how to work with files. For C, the Emscripten compiler apparently supports embedding files into a virtual file system. Does the go command provide an equivalent when generating .wasm files? Should I use Packr

Re: [go-nuts] Re: GoAWK: an AWK interpreter written in Go

2018-11-26 Thread Scott Pakin
On Friday, November 23, 2018 at 1:58:37 PM UTC-7, Ben Hoyt wrote: > > So my main suggestion (for spakin/awk) would be able to wrap os.Stdout in > a bufio.NewWriter (and be sure to call Flush before Run finishes). If the > user wants to pass an unbuffered version, they still can, but at least the

Re: [go-nuts] Re: Go 2 error-handling counter-proposal: returnfrom

2018-09-14 Thread Scott Pakin
On Friday, September 14, 2018 at 12:30:46 AM UTC-6, rog wrote: > > What about here, where the call stack associated with g is still live? > > func g() error { > Top: > f := func(err error) { returnfrom Top, nil } > c := make(chan struct{}) >

[go-nuts] Re: Go 2 error-handling counter-proposal: returnfrom

2018-09-13 Thread Scott Pakin
On Thursday, September 13, 2018 at 4:00:28 PM UTC-6, Jonathan Amsterdam wrote: > > What's the meaning of this code? > >func main() { >f := g() >f() > } > >func g() func() { >Top: >return func() { returnfrom Top, nil} >} > It means you're an evil progr

[go-nuts] Go 2 error-handling counter-proposal: returnfrom

2018-09-13 Thread Scott Pakin
I recently added to the Go 2 Error Handling Feedback page my thoughts on how to improve upon the draft design for error handling : Go 2 error handling b

[go-nuts] Re: GoAWK: an AWK interpreter written in Go

2018-08-27 Thread Scott Pakin
On Friday, August 24, 2018 at 3:13:25 PM UTC-6, Ben Hoyt wrote: > > I recently wrote an AWK interpreter in Go: > https://github.com/benhoyt/goawk > > It's a pretty simple implementation: hand-rolled lexer, recursive-descent > parser, and tree-walk interpreter. It's pretty complete according to th

[go-nuts] Re: Go could really use a while statement

2018-05-09 Thread Scott Pakin
On Wednesday, May 9, 2018 at 4:59:35 PM UTC-6, matthe...@gmail.com wrote: > > I’m not sure if C has been directly mentioned. I started with C so > iteration is just a nice shortcut to me. Assuming you’ve always had > collection iteration available an explanation is the for loop can make the > us

[go-nuts] Re: Flag package issue when nonflag argument string begins with a minus sign

2018-01-24 Thread Scott Pakin
On Wednesday, January 24, 2018 at 11:00:37 AM UTC-7, erisa wrote: > > I have a CLI program that uses the flag package and has one flag and takes > a string as its only nonflag argument. The string can be a complex > expression, but it is possible that the first character of the string is a > mi

Re: [go-nuts] Doing "C-like" things in Go

2017-09-18 Thread Scott Pakin
On Monday, September 11, 2017 at 7:25:54 PM UTC-6, Michael Jones wrote: > > int(boolvalue) could mean 0 for false and 1 otherwise > bool(intvalue) could mean false for 0 an true otherwise > > quite a useful notion > Yeah, too bad that was shot down years ago (cf. proposal: support int(bool) conv

[go-nuts] Re: Explain the meaning of iota

2017-07-01 Thread Scott Pakin
On Friday, June 30, 2017 at 9:28:50 PM UTC-6, Manohar Reddy wrote: > > `iota` is golnag's enum. I've seen this code in Wikipedia. But I did not > understand it. Can someone please explain this code? > In the first line of the const block, iota is 0, and this is assigned to "_" (i.e., discarded).

[go-nuts] [ANN] New package for interning strings

2017-06-20 Thread Scott Pakin
I just released a package called intern for speeding up string comparisons. Install it in the usual manner: go get github.com/spakin/intern The package defines two interned-string types, Eq and LGE, and functions to allocate them. Internally, both are repre

[go-nuts] Re: Reading stdlib for education about go?

2017-05-12 Thread Scott Pakin
On Friday, May 12, 2017 at 4:39:54 AM UTC-6, Steve Mynott wrote: > > What parts of the go stdlib are particularly useful for self education > in general go? > It's been a while since I looked, but I recall image/png (or any of its file-format siblings) and i

[go-nuts] Re: File path extractor Regexp

2017-03-02 Thread Scott Pakin
On Thursday, March 2, 2017 at 6:50:16 AM UTC-7, Nyah Check wrote: > > I am currently developing an application that identifies strings looking > like a file path and collects them and returns the array of strings. Over > the past week, I developed a regex to identify file paths to this: > "(?:/

[go-nuts] Re: bit twiddling API survey

2017-01-10 Thread Scott Pakin
On Monday, January 9, 2017 at 6:07:19 PM UTC-7, ma...@influxdb.com wrote: > > I haven't personally experienced a need for a bit twiddling API, but if > you're looking for other interesting operations, you might want to check > out the awesome-bits curated list of bitwise operations [1]. > > [1] h

[go-nuts] Re: In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-30 Thread Scott Pakin
On Monday, August 29, 2016 at 5:51:42 PM UTC-6, Eric Johnson wrote: > > Not that I think these account for much, but sort of fun to point at: > > https://benchmarksgame.alioth.debian.org/u64q/go.html > (Short summary - now with Go 1.7, Go is faster for most benchmarks.) > Go 1.7 is faster than C o