Re: [go-nuts] Slices and inconsistency

2020-06-26 Thread howardcshaw
"If the capacity of s is not large enough to fit the additional values, append allocates a new, sufficiently large underlying array that fits both the existing slice elements and the additional values. Otherwise, append re-uses the underlying array." That seems pretty explicit to me? That's

[go-nuts] Re: Speed up png.Decode

2020-06-26 Thread howardcshaw
I don't know if the CGo transitions for 16 million images will completely swamp the speed gains, or how much post-processing you need to do to these images, but you might try and see if it gives you any wins. It claims 'typically 4x faster' then the Go Image

[go-nuts] Re: Why the user variable isn't getting printed when the query is alright

2020-06-24 Thread howardcshaw
First, please post plain text. Second, you are not capturing the error from the query; capture and print that error and it will likely inform you what the issue is. (On the row.Scan.) Third, perhaps the issue is your use of $1 instead of ?. This is regarding sqlx, but the issue they describe

[go-nuts] Re: [generics] I think it's better have higher perfomance than lower compiling time

2020-06-19 Thread howardcshaw
I think in general this is not the attitude of the Go developers, nor the Go community - fast compilation was an explicit design goal of the original creation of Go (as a reaction to slow compile times with C++), and has remained a concern. >From the FAQ,

Re: [go-nuts] Go has confusing pointers

2020-06-19 Thread howardcshaw
c is of type *Count (pointer to Count), surely? It is (*c) that is of type Count, which has to be cast to int to be returned as such because Go requires explicit casts. Agree with the rest. On Friday, June 19, 2020 at 12:44:26 PM UTC-5, Tyler Compton wrote: > > In this case, c is of type Count,

[go-nuts] Re: Does os.exec work ?

2020-03-25 Thread howardcshaw
What you are really wanting there is to run xsel --clipboard and pipe data into it. Talk to your cmd.Stdin! This is mostly straight from the StdinPipe example in the go docs: cmd := exec.Command ("xsel","--clipboard" ) stdin, err := cmd.StdinPipe() if err != nil { log.Fatal(err) } go func() {

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

2020-03-12 Thread howardcshaw
> > let blob = new Blob([buf], {'type': imageType}); >> document.getElementById('targetImg').src = URL.createObjectURL(blob); >> } >> > > I see. In your case, targetImg is an , right? Do you know how I > could use this same technique with a ? > > If the was off-screen or hidden,

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

2020-03-11 Thread howardcshaw
I've no relevant experience, but I can recommend a couple of projects to look at in the absence of anyone chiming in with actual experience: This is a play-project that involves loading images. It appears to

[go-nuts] Re: [ANN] Renderview v0.1.0 with go mod, Gio, and Fyne support

2020-02-25 Thread howardcshaw
I worked it out, will update the programs later. It was not that the events were missing - once I enabled the good old Printf debugger, I saw that the events are flowing fine. The issue is that on Linux, every Move Mouse event reflected what buttons were pressed the entire time they were

[go-nuts] Re: [ANN] Renderview v0.1.0 with go mod, Gio, and Fyne support

2020-02-22 Thread howardcshaw
As far as Windows goes, the Shiny backend works fine to draw a pannable, zoomable image with Renderview on Windows, and as far as I am aware, requires no further dependencies. But there is still not an editable text widget in Shiny, and while I was able to find a third-party multi-line text

[go-nuts] [ANN] Renderview v0.1.0 with go mod, Gio, and Fyne support

2020-02-21 Thread howardcshaw
Four years ago I posted Renderview, a simple GUI wrapper that lets you take any image generation function in your code and turn it into an interactive GUI program with panning, optional zooming, and depending on backend choice, parameter editing. I have

Re: [go-nuts] Why isn't there strings.reverse("str") function?

2020-02-18 Thread howardcshaw
My most common use case for reversing strings has not come up in Go yet - basically, some languages provide a string search function that finds a character or substring starting from the beginning of the string. For example, in T-SQL, CharIndex. If they do not provide a corresponding search

[go-nuts] Re: issue with yaml processing

2019-12-26 Thread howardcshaw
You want to add the flow directive to the struct's attributes. From the docs: flow Marshal using a flow style (useful for structs, sequences and maps). type Config struct { Contents []string `yaml:"contents,flow"` } Howard -- You received this message because you

[go-nuts] Re: Adding dimension to 2d slice loses dimension order

2019-10-16 Thread howardcshaw As you can see here, wrapping a 2d slice inside of a 3d slice does not affect the ordering. Look to see if you use a map anywhere - the order of map keys is not preserved, and indeed is deliberately randomized. Beyond that, add tests and printfs to narrow

[go-nuts] Re: SSA-able and canSSA meaning in Go compiler's SSA backend?

2019-09-19 Thread howardcshaw
Read this wiki page to understand what the goal is: Basically, SSA-form allows certain optimizations that are harder without it, but SSA is also itself hard to apply. SSA examples are often posed in the form of simple variables, but

[go-nuts] Re: SSA-able and canSSA meaning in Go compiler's SSA backend?

2019-09-19 Thread howardcshaw
Read this wiki page to understand what the goal is: Basically, SSA-form allows certain optimizations that are harder without it, but SSA is also itself hard to apply. SSA examples are often posed in the form of simple variables, but

[go-nuts] Re: SSA-able and canSSA meaning in Go compiler's SSA backend?

2019-09-19 Thread howardcshaw
Read this wiki page to understand what the goal is: Basically, SSA-form allows certain optimizations that are harder without it, but SSA is also itself hard to apply. SSA examples are often posed in the form of simple variables, but

Re: [go-nuts] Re: Question re fcns that return multiple values

2019-08-07 Thread howardcshaw
On Wednesday, August 7, 2019 at 8:45:18 AM UTC-5, wrote: > > f( g() ) compiles when g returns exactly the number of args that f() > requires, but if g() returns only 1/2 that number f (g(), g() ) wont > compile !! ...Is this not a Golang absurdity ?? > >> >> Eh. Certainly

[go-nuts] Re: Any alternative to go-bindata that supports dynamic assets?

2019-05-29 Thread howardcshaw
Just a suggestion, Mark - instead of L.DoString(string(file)) in response to a failure on L.DoFile (is there no other error that can occur there other than the file being missing?), do an explicit test for the file existing, and if it does not exist, grab the asset from bindata and *write it

Re: [go-nuts] Re: io.Copy and Writer

2019-05-22 Thread howardcshaw
Except that as the example I gave showed, it is fairly trivial to wrap the bufio.Writer into a WriteCloser that retains that reference and performs the pass-through Close as expected. So if you have a situation that needs a WriteCloser, you can manage that. Meanwhile, the bufio classes provide

Re: [go-nuts] Re: io.Copy and Writer

2019-05-21 Thread howardcshaw
Excuse me if I am misunderstanding something - but it certainly looks to me like you are not at any point closing the bufio.Writer (because it is not a WriteCloser and does not support Close function). That is why you need to flush it! What you are closing is the underlying

Re: [go-nuts] Re: Web access to golang-dev is down

2019-05-07 Thread howardcshaw
Sorry, forgot to include: Yes, I can access golang-nuts, no errors. Golang-announce works fine, neovim gives the error. Clojure works fine. Howard -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Re: Web access to golang-dev is down

2019-05-07 Thread howardcshaw
I get the error online as well, using!golang-dev Refreshing the page has no effect. Incognito mode, not logged in, gives the same error. Google Chrome 74.0.3729.131 (Official Build) (64-bit) (cohort: Stable) IP is in the block. Firefox Version 67.0b12

[go-nuts] Re: If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread howardcshaw
I believe that by default, Go programs are statically linked. >From the man page for otool: *-L* Display the names and version numbers of the shared libraries that the object file uses, as well as the shared library ID if the file is a shared library. This

[go-nuts] Re: Have Any One Experience With Print CSS Modules Using in Golang

2019-03-22 Thread howardcshaw
That is just a wrapper for wkhtmltopdf - I'd suggest looking into that library and tool first. If you can get the wkhtmltopdf command line tool to convert your file happily, then getting the Go wrapper to do the same is probably possible. But if the command line tool

Re: [go-nuts] Accessing *[]uint64 from assembly - strange memory corruption under heavy load - any ideas?

2019-03-22 Thread howardcshaw
On Friday, March 22, 2019 at 12:27:37 AM UTC-5, Tom wrote: > > The allocation is in go, and assembly never modifies the size of the > backing array. Assembly only ever modifies len, which is the len of the > slice and not the backing array. > > Can the assembly ever modify len to a size greater

Re: [go-nuts] why slice[len:len] okay, but slice[len] fail?

2019-03-08 Thread howardcshaw
> Could you please explain, why primes[6:6] okay, but primes[7:7] not? Here you go: Given this as a slice: [2:3:5:7:11:13] consider primes[6:6]'s meaning. [2:3:5:7:11:13] [ ] 'return the slice starting after the last element of primes and ending after the last

Re: [go-nuts] I found a very strange code that would cause deadlocks and blocking,why???

2019-02-28 Thread howardcshaw
Sameer is correct, but to be clear - The *block* happens because the channel is empty, so the receive operation blocks forever. This happens in both of the cases you show. The *deadlock* happens because *all* goroutines are blocked and none can continue. So if you start some other goroutine

[go-nuts] Re: Algorithm question: reversing text/template.Template.Execute efficiently

2019-01-17 Thread howardcshaw
I don't think the problem is well-defined or single-solution. Surely the simplest solution, given a single output and the data that produced it is to simply encode the entire output text in the template and ignore the data. Instead, I think you need a matching corpus - i.e. a list of pairs of

Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-17 Thread howardcshaw
I was not responding to it being or not being metaprogramming, just the implication that go generate commands were provided some sort of special access. They do not have any access to parsed syntax trees - they can themselves parse source files and thus create syntax trees. On re-reading, I

Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-14 Thread howardcshaw
Not sure where you got this impression - commands run by go generate have only the OS environment. They are just ordinary commands, as might be run by any shell script, just the calls to them are integrated into the Go tooling. Tools that seem to access go syntax trees and the like? They are

[go-nuts] Re: navigating through interface calls

2018-12-07 Thread howardcshaw
It is rather the point of interfaces that there IS no fixed definition of an instance of an Interface call. The definition could be that of ANY struct that matches that interface, depending on what is passed. So yes, you have to find AN instance of a call to the function that accepts an

[go-nuts] Re: Template function arguments from JS

2018-10-18 Thread howardcshaw
I have not done much with golang on the web, so take this with a grain of salt. You are right in judging why it does not work - by the time the Javascript runs, the template generation is long over with. That said, I think you have two basic options: Option 1: Front-load the data into

Re: [go-nuts] Re: [ANN] A blog post series on serving big satellite imagery with Go

2017-12-21 Thread howardcshaw
To consider for your series, at some point down the line: There are standards for serving geo-located tiles, and if you match one of them, your little Go program can serve tiles to already existing map browsers, from Javascript based slippy-maps, to Android or iOS street-map viewers, to full

[go-nuts] Re: static analysis tool for detecting unclosed io.Closer's

2017-12-20 Thread howardcshaw
In the absence of an affirmative, I'll just say that I did a search of my own. This site: lists a bunch of static analysis tools for go. has another list, and will run them for you. They have binary

[go-nuts] Re: XML Pretty Print

2017-12-20 Thread howardcshaw
One thing to consider is what level of change to the file is acceptable? If it is just to be human read, than the suggestions already given may do what you want; but it you want to take that result and preserve it for future use, then the mxj and the encoding/xml based methods may produce

[go-nuts] Re: Go Generate Vs Go Build!

2017-12-20 Thread howardcshaw
Go generate is not needed in your example. Go build is what is producing the hello executable. Go generate is used to run special commands specified by comments in the .go files - these commands could produce new .go files, package binaries into binhex or base64 encoded strings in .go files

[go-nuts] Re: Calculation of the combinations between an unlimited number of slices

2017-12-08 Thread howardcshaw
When you use append, two different things can happen: 1. There is enough capacity in the original slice to which you are appending to add the additional values. You get a slice that points to the same backing memory. 2. There is not enough capacity in the original slice to which you are

[go-nuts] Re: Union types mindset

2017-11-21 Thread howardcshaw
In addition to Joshua's suggestion, I would point to Composition. Something like this: // Anything with a GetComment implicitly implements this Interface type AsmComment interface { GetComment() string // presuming any line could have a comment } type AsmEntry interface {

[go-nuts] Re: golang and http2

2017-11-15 Thread howardcshaw
See - for discussion of the issue; and for a way to use the in stdlib-but-not-linked-together support for h2c (http/2 over non-TLS). Howard -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: How to returns the index of the first instance in uint32 slice?

2017-11-14 Thread howardcshaw
You certainly can implement such a thing. The source to the bytes Index function is in the bytes_platform.go files, as it is optimized per platform: is the amd64 one, for example. Looking at it is a good way to see how such a thing is implemented. A

[go-nuts] Re: How to convert from []byte to []uint32?

2017-11-13 Thread howardcshaw
The hack would be to use unsafe after converting it to a byte slice to cast to a Pointer and cast that back to a uint32 slice. This is bad. Do not do this. Go's ethos is pretty strongly against 'super cool hacks' or 'code golf' style statements that perform magic to stuff a lot of code into

[go-nuts] Re: Handling dynamic and unknown number of wait groups?

2017-11-02 Thread howardcshaw
You absolutely can use goroutines without waitgroups! It all depends on what you are doing with them. Where waitgroups come in is when you need to something only after *all* of the goroutines on a specific task are done. Chances are that if you are not using waitgroups, you are either using

[go-nuts] Re: Mermaid parser

2017-10-27 Thread howardcshaw
There is not one currently that I've seen; there are reasonably good SVG libraries for Go though, and it might be possible to take the Javascript code and convert it to Go fairly mechanically to make a start on one. appears to do something like that for the

[go-nuts] Re: How to convert byte slice to UUID?

2017-10-18 Thread howardcshaw
I don't know if you are going to get very far on that, as it seems to have been a deliberate change: " It differs from these earlier packages in that a UUID is a 16 byte array rather than a byte slice." Looks from here: like being able to use them as

Re: [go-nuts] Alternative to reflect.DeepEqual that considers "shape" of cycles?

2017-07-27 Thread howardcshaw "Pointer values are deeply equal if they are equal using Go's == operator or if they point to deeply equal values." By the rules described here, the fact that both pointers have the same value means it does not even NEED to check what they point to, so

Re: [go-nuts] encoding/csv: Is this a bug?

2017-07-24 Thread howardcshaw
encoding/csv uses the io.Reader interface, so wouldn't you just need a CR->CR/LF filter that fulfills that interface? Something like should do the trick. Though it would be annoying to deal with when writing a generic program for handling arbitrary input, if

[go-nuts] Re: map[X]Y or map[X]*Y ?

2017-05-12 Thread howardcshaw
> > type Y struct { > //some fields > } > > This rather depends on what those some fields ARE, and whether type Y is conceptually mutable or immutable. For example, I might make a lightweight struct just to group a pair of values; X/Y coordinates, or Latitude and Longitude: type LatLon

[go-nuts] Re: [ANN] Gobot v1.5.0 released

2017-05-10 Thread howardcshaw
Might want to mention what that IS so people know whether they care to click link. Gobot is 'Next generation robotics/IoT framework with support for 29 different platforms' according to their website. (IoT is Internet of Things, meaning internet-connected appliances/tools/non-traditional

[go-nuts] Re: RTP/RSTP and OVNIF?

2017-05-03 Thread howardcshaw lists several for rstp. I have not used any, so I cannot recommend one over another. As for ONVIF, I don't know of any implementations, but it is just a SOAP api, so generic SOAP programming should be enough to interact with it, I believe. Here is a SOAP/WSDL

[go-nuts] Re: Can ServerMux serve two different handler functions on / and a path beyond / ?

2017-03-01 Thread howardcshaw
I think at that point you have to step up to one of the muxers - Gorilla is a popular choice in the ecosystem. Their example: func main() { r := mux.NewRouter() r.HandleFunc("/", HomeHandler) r.HandleFunc("/products", ProductsHandler)

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread howardcshaw
Look a little further down - they are documented in the ByteOrder type. A ByteOrder specifies how to convert byte sequences into 16-, 32-, or 64-bit unsigned integers. type ByteOrder interface { Uint16([]byte ) uint16

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread howardcshaw
You are missing that it is encoding. Specifically, using VarInt is asking for Variable integer encoding: The important bit here is that the Varint stores 7-bits of data and 1-bit of metadata in each byte (the metadata being

[go-nuts] Re: [Newbie] Create PNG from 2D Array and Write Over HTTP

2017-02-27 Thread howardcshaw
You could define the colors higher in the package - right now you are allocating them every time, but they are not changing. You could also also retain the image and simply wipe and rewrite it every time as long as it is not happening in a goroutine in multiple places - if so, you could retain

[go-nuts] Re: go/types.Typ is a slice-of-pointer-to-struct yet uses map syntax

2017-02-15 Thread howardcshaw
Invalid, Bool, Int, Int8 there are const integers, and they are specifying the entry's position in the slice, allowing gaps in the list to be implicitly defined. See this example: -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: Compressing 2.5 GB data trims files

2017-02-15 Thread howardcshaw
While it is not clear from the Buffer documentation, the Reader *interface* documentation (which Buffer.Read implements implicitly) does state "up to len(p) bytes." You are ignoring how many bytes it read and assuming that the one read is reading the whole file. I am not sure that this is

[go-nuts] Re: Generate string to enum using stringer.

2017-02-15 Thread howardcshaw
It already has been! Álvaro has done this for you. This is a fork of stringer that has the function you want: - A function String(s string) to get the enum value from its string representation. This is useful when you need to read enum values from

Re: [go-nuts] CodeReviewComments: Recommendation of gofmt

2017-02-15 Thread howardcshaw
> > > > Side-note: I don't think goimports can actually do what you are saying, > can it? Because, if you run goimports on a valid program, it won't actually > *change* any imports, it might just reformat it. For goimports to change > anything semantically, the program would need to have

[go-nuts] Re: Returning an interface using a concrete type?

2017-02-15 Thread howardcshaw
It can, as I see you've already discovered - but at the same time, should it? I think the current 'received Go wisdom' in the community seems to be 'Accept interfaces, return structs' - So you

[go-nuts] Re: how to parse script expression with go and run the script

2017-02-15 Thread howardcshaw
The go/parse package is not really going to help much, as Go is a compiled language. What you are wanting is something akin to a scripting language, something with an 'eval' type function. While it is just barely feasible that you could accomplish something directly with Go using on-the-fly

[go-nuts] Re: Does my gofmt work wrongly or I don't understand something ?

2017-02-05 Thread howardcshaw
What were you expecting to happen? The documentation says: Both pattern and replacement must be valid Go expressions. In the pat‐ tern, single-character lowercase identifiers serve as wildcards match‐ ing arbitrary sub-expressions; those expressions will be

[go-nuts] Re: Pass variables to bash

2017-02-02 Thread howardcshaw
I don't think you can do what you want to do, precisely. But, I do think you can solve your problem! Instead of actually writing to your environment in the Go code (which can only be seen by *child* processes *of the Go program*!), just print to stdout. That is, instead of

[go-nuts] Re: XML unmarshal woes

2017-02-02 Thread howardcshaw
Here is a playground link: ABStuff string `xml:",innerxml"` You can capture the innerxml with an appropriate tag; you can also, as my third example in the above link demonstrates, capture multiple repeated tags like that to a list of values. If, as I think

Re: [go-nuts] Why do these Printfs output different things?

2017-01-24 Thread howardcshaw
Actually, the explanation is a little further down in the docs, specifically, this paragraph: For floating-point values, width sets the minimum width of the field and precision sets the number of places after the decimal, if appropriate, except that for %g/%G precision sets the total number of

[go-nuts] Re: Marshal more than one XML line?

2017-01-17 Thread howardcshaw
If you actually run that example (click Run below it), you will see it is actually writing out eleven lines of XML. If you had two persons, then you would not be marshalling each individually, generally. Instead, you would marshal a slice or array of persons. See this example:

[go-nuts] ANN: rosarygen 1.0

2017-01-03 Thread howardcshaw
This will probably have a very narrow audience (intersection of golang-nuts readers and Catholics), but may serve as an example of functional audio-processing in Go. For those unaware, in the Catholic faith, the Rosary is a collection of prayers meant to be said while meditating, often with

[go-nuts] Re: Merging Data Structures in Go

2016-11-21 Thread howardcshaw
What is the intended use-case for this? Depending on the purpose, you might have a look at mergo, as it does something similar, mostly for pulling configuration settings from multiple places and combining them with defaults. For JSON maps, there is

[go-nuts] Re: Why is src modified when concatenating slices with dst = append(dst, src[:i])

2016-11-21 Thread howardcshaw
Your solution certainly works - but because you allocate a smaller slice than you need in the end, it is going to allocate and copy *again* as soon as you hit your second append. You could instead use the other form of make (three parameter) to create an *empty* slice with the full length

[go-nuts] Re: [ANN] (GUI) Qt binding which supports Windows / macOS / Linux / Android / iOS / Sailfish OS / Raspberry Pi

2016-11-17 Thread howardcshaw
What version of QT is it intended to be built against? I get therecipe/qt/core/core.cpp:9:30: fatal error: QAbstractAnimation: No such file or directory when I try to build against it, or when trying to build the renderer example. qt5-default says it is 5.5.1+dfsg-16ubuntu7.2 and

[go-nuts] Re: [ANN] (GUI) Qt binding which supports Windows / macOS / Linux / Android / iOS / Sailfish OS / Raspberry Pi

2016-11-15 Thread howardcshaw
therecipe, is there a means available to render image.Image or draw.Image (go Image) objects to Qt images/buffers/etc? I was not able to locate such a facility in several other libraries. In the end I got fed up and wrote my own for converting a draw.Image to a GdkPixBuf to get gtk2 and gotk3

Re: [go-nuts] Re: ANNOUNCE: renderview

2016-08-28 Thread howardcshaw
Alright, gotk3 appears to be working properly now. I found the right function - I had found set_surface_pixbuf in the GTK3 docs, but thought it missing from the gotk3, until a helpful page pointed out that it was *not* a Cairo function, and took the Cairo context as a parameter instead. So,

Re: [go-nuts] Re: ANNOUNCE: renderview

2016-08-28 Thread howardcshaw
I still have not tested on Windows; I did look up and find some documentation on how to get go and gtk installed and working together on Windows, and it basically boils down to installing the linux version of go under mingw.

Re: [go-nuts] Re: ANNOUNCE: renderview

2016-08-27 Thread howardcshaw
Thanks, Nigel. I've updated as you recommended. Remember to use -u to tell go get to fetch it fresh from github. go get -u On Saturday, August 27, 2016 at 7:21:12 PM UTC-5, Nigel Tao wrote: > > > Yeah, all of the "renderview" imports need to be >

[go-nuts] ANNOUNCE: renderview

2016-08-27 Thread howardcshaw
I mentioned this on the list a little while back in a discussion on Shiny, and now it is finally up and available. So... what is it? RenderView is a simple GUI wrapper that makes it easy to wrap any image generation function and make it interactive. It

Re: [go-nuts] Re: Shiny

2016-08-16 Thread howardcshaw
On Tuesday, August 16, 2016 at 12:19:13 PM UTC-5, Dave MacFarlane wrote: > > What do you mean "no actual text editors"? By my count of the > importers that GoDoc knows about 3 out of 8 of the projects that are > using it are text editor apps. > > - Dave > Go to exp/shiny/examples/textedit.

[go-nuts] Re: Shiny

2016-08-16 Thread howardcshaw
I've been working with it lately. I got fairly far in writing a drop-in visualizer for my algorithms, but I ran into a snag when I went to add dynamically generated editing for parameter values. The widget.NewText(), in spite of being used in an Example called TextEdit, does not appear to