Re: [go-nuts] How to call sort.Search in a loop

2022-10-11 Thread K. Alex Mills
Ah, my last post had a small mistake. A small modification to upper should be all you need. The function should use >= instead of >. See below. upper := sort.Search(len(haystack), func(i int) bool { return haystack[i].name >= needle.name }) On Tue, Oct 11, 2022, 7:38 AM K. A

Re: [go-nuts] How to call sort.Search in a loop

2022-10-11 Thread K. Alex Mills
sort.Search runs binary search. It's only guaranteed to work when you provide it with a function which is monotonic -- true at index i implies true at all indices greater than i. Your loop style search does not provide a monotonic function, whereas your "upper" function is monotonic. However,

Re: [go-nuts] Is there a better way to write this?

2022-09-15 Thread K. Alex Mills
The only alternatives that I see would each introduce an extra call to Add, like the below. I'm not sure if this is much less "clunky", but it at least avoids the reassignment to s. func collectStringsetMap(m map[string]*stringset.Set, key string, value ...string) *stringset.Set { if s, ok :=

[go-nuts] github.com/splunk/pipelines hits v1.0.0

2022-08-20 Thread K. Alex Mills
and combine pipeline stages as pairs. * Handle fatal and non-fatal errors from any pipeline stage. * Sinks for draining the result of a pipeline computation. Some future enhancements are planned. Please leave any suggestions or issues in the issue tracker. Thanks K. Alex Mills -- You received

Re: [go-nuts] Re: Why declaring multiple variable at once for same type feature exists in Golang?

2022-08-18 Thread K. Alex Mills
Yes. Declaring i and j on the same line is certainly cleaner. We should all do it like that. Am I missing something? On Thu, Aug 18, 2022, 9:25 PM Yasser Sinjab wrote: > Thanks, I don't object it personally, but I had a debate about "grouping > variables is considered a clean code". > > Let's

Re: [go-nuts] gofmt 1.19 reformats comments in a way which breaks go-swagger

2022-08-17 Thread K. Alex Mills
I would hesitate to call this a bug in gofmt. Go released new godoc features as part of Go 1.19, along with reformatting of comments. Those features were entirely intentional. The decision made in the go-swagger project to place its comments alongside godoc comment blocks was a risky one in case

Re: [go-nuts] Application Monitoring

2022-08-16 Thread K. Alex Mills
Monitoring and observability are best practices regardless of what language you use. We use a combination of Prometheus / Grafana and metrics exported by runtime/metrics. We also include custom metrics tailored to our application's use-case. Prometheus is not a standard Linux tool, but it is open

Re: [go-nuts] Pipelining with Go and Generics

2022-08-11 Thread K. Alex Mills
thod like Map() on a stream instance can’t be > written - because the stream is of type T, and the Map() produces a stream > of type R. > > psuedo code: > > type Stream[T any] interface { > ... > Map[R any](func (T) R) Stream[R] // syntax not supported > ... >

Re: [go-nuts] Pipelining with Go and Generics

2022-08-11 Thread K. Alex Mills
Ah, my apologies, I was wrong. Panicking in the midst of a func passed to one of these pipeline stages most certainly *will not* shut down the entire pipeline and cannot be recovered like I had suggested. Sorry about that. Sincerely, K. Alex Mills On Thu, Aug 11, 2022 at 4:56 PM K. Alex Mills

Re: [go-nuts] Pipelining with Go and Generics

2022-08-11 Thread K. Alex Mills
o with this library. Just use recover at the top of the func that spins up the pipeline and use context.WithCancel to shut the rest of the pipeline down in that case. Let me know if that's unclear and I'll do my best to provide an example. Sincerely, K. Alex Mills On Thu, Aug 11, 2022 at 4:18 PM

Re: [go-nuts] Pipelining with Go and Generics

2022-08-11 Thread K. Alex Mills
mpossible with error returns. > > A streams api with panic/recover is needed. > > On Aug 11, 2022, at 12:55 PM, K. Alex Mills > wrote: > >  > Hello Gophers, > > I recently had an opportunity to try out Go generics on a small pipelines > package <https://pkg.go.dev/

[go-nuts] Pipelining with Go and Generics

2022-08-11 Thread K. Alex Mills
/kalexmills.com/journal/pipelines/>. I'm open to any of your thoughts, suggestions, and issue reports. Sincerely, K. Alex Mills -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving e

Re: [go-nuts] ast.NewPackage errors for built in types

2021-10-17 Thread K. Alex Mills
I'm guessing here, but you probably do need the full type-checker for that, depending on what you mean by "a native type". In go we can alias types in two ways. type A uint8 type B = uint8 There are subtle differences between the two which I don't claim to understand... In any case, AFAIK both

Re: [go-nuts] ast.NewPackage errors for built in types

2021-10-15 Thread K. Alex Mills
FWIW: I'm not surprised that it's slower because it's handling significantly more of the compilation. The parser is very fast. Adding in type-checking is going to be less fast. IIRC, the packages package also has to make network calls and do filesystem I/O behind the scenes in some cases. The

Re: [go-nuts] ast.NewPackage errors for built in types

2021-10-12 Thread K. Alex Mills
It's been several months since I used these packages but IIRC, go/ast only requires code to parse correctly, while go/types actually runs the type-checker. Running the type checker implies having a complete picture of all the types used in a Go program, which, in my recollection, usually means

Re: [go-nuts] HTTP request reading

2021-04-29 Thread K. Alex Mills
Partial responses inline, HTH. On Thu, Apr 29, 2021, 6:09 AM Amit Saha wrote: > Hi all, when an incoming request comes in, does the ListenAndServe() > function read the first line (as explained in > https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages) to figure > out whether there is a

Re: [go-nuts] go text://protocol client?

2021-04-11 Thread K. Alex Mills
On Sun, Apr 11, 2021, 5:15 AM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > On Sun, Apr 11, 2021 at 5:11 AM Kurtis Rader wrote: > >> >> It is nice that the specification allows for an efficient implementation. >> But I agree with Dan that your documentation is opaque, obtuse,

Re: [go-nuts] Update to generics proposal

2021-04-04 Thread K. Alex Mills
This seems like a welcome change and leaves the door open for the future inclusion of type unions. Nicely done! Regarding this approximation operator, I have a question about the intended meaning of: ~struct{ F int A string } Would this match the following types? type A struct{ F int A

[go-nuts] Re: Type-checking from Memory?

2021-01-23 Thread K. Alex Mills
portant for some use-cases. For my purposes, I want to avoid downloading / type-check module dependencies anyway. Sincerely, K. Alex Mills On Wed, Jan 20, 2021 at 8:03 PM K. Alex Mills wrote: > Hi All, > > Right now, I can run the type-checker by writing the GitHub tarball > conten

[go-nuts] Type-checking from Memory?

2021-01-20 Thread K. Alex Mills
large part of what packages provides? Thanks, K. Alex Mills -- 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. To

Re: [go-nuts] Thread safe tree library?

2021-01-08 Thread K. Alex Mills
> I was thinking of potential issues if you rebalance the tree as an example. > > I’m not certain what issues could arise as I’ve never considered a > concurrent data structure that lacks some kind of synchronisation for both > read and writes unless it’s immutable copy-on-write or similar. > > Do

Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread K. Alex Mills
On Tue, Jan 5, 2021, 6:59 PM Nathan Fisher wrote: > Does write only locking provide read correctness? I would’ve thought based > on the memory model it could cause issues? > > https://golang.org/ref/mem#tmp_2 > It depends on your notion of "read correctness", specifically when you consider each

Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread K. Alex Mills
That is the simplest and most conservative way go about it, but ultimately it depends on what you need out of your concurrency semantics. If you're willing to settle for a linearizable execution, you can gain some performance improvements by only checking the lock for write operations. So long as

Re: [go-nuts] Re: The GitHub Vet Project

2021-01-01 Thread K. Alex Mills
> Technically, I believe a range loop variable can be used in a goroutine >> safely. A very contrived example: https://play.golang.org/p/jgZbGg_XP6S . >> In practice I can not see much use for this kind of pattern, but it does >> exist. >> > > It is correct that the range loop variable can be used

Re: [go-nuts] Signature Switch - third path to Go generics

2020-12-31 Thread K. Alex Mills
At a glance, this feels to me like it is more complicated than the current generics proposal. That said, it also seems very original so I have to give credit there. This proposal seems to put the responsibility for monomorphizing generic code onto the programmer. I'm not sure why it would be

Re: [go-nuts] The GitHub Vet Project

2020-12-30 Thread K. Alex Mills
ing has just pointed out a few other concerns like pointer comparison and finalizers for which analyzers have yet to be written. My perception is that these two features aren't very widely used, so I wouldn't expect to find a large number of instances like these. > On Sun, Dec 20, 2020 a

Re: [go-nuts] Re: The GitHub Vet Project

2020-12-30 Thread K. Alex Mills
mentioning that there are issues which loopclosure misses >> which VetBot is able to find, and the community's effort will still be >> needed to help sift through false-positives once the project has stabilized. >> >> >> On Sun, Dec 20, 2020 at 12:08 PM K. Alex Mills >>

[go-nuts] Re: The GitHub Vet Project

2020-12-29 Thread K. Alex Mills
misses which VetBot is able to find, and the community's effort will still be needed to help sift through false-positives once the project has stabilized. On Sun, Dec 20, 2020 at 12:08 PM K. Alex Mills wrote: > Hello Gophers! > > During a Q session at this year's GopherCon, some me

Re: [go-nuts] [generics] Print[T Stringer](s []T) vs Print(s []Stringer)

2020-12-27 Thread K. Alex Mills
nt performance > implications for low-level/tight-loop functions as it will avoid the > indirection required for interface method dispatching (at the expensive of > code explosion for common calls with lots of types). > > On Dec 27, 2020, at 11:31 AM, K. Alex Mills > wrote: >

Re: [go-nuts] Re: [generics] Print[T Stringer](s []T) vs Print(s []Stringer)

2020-12-27 Thread K. Alex Mills
hole thing as far as I am concerned. > > Cheers > > On Sun, 27 Dec 2020, 05:25 K. Alex Mills, wrote: > >> While it depends on the final generics implementation, my understanding >> of how things stand now is that Print would compile down to a separate >> chunk of binary

Re: [go-nuts] Re: [generics] Print[T Stringer](s []T) vs Print(s []Stringer)

2020-12-26 Thread K. Alex Mills
While it depends on the final generics implementation, my understanding of how things stand now is that Print would compile down to a separate chunk of binary for each type T that is used. For instance, if you used Print[A] and Print[B] in your code, they would each refer to separate binary

[go-nuts] [generics] go2go snippets -- repository of example solutions to problems using generics

2020-12-24 Thread K. Alex Mills
For my part, I see some value in maintaining a source of example solutions to problems that generics could solve. Since I was not aware of any resource that attempts to gather together several example implementations in one place (and couldn't find one after a couple minutes of searching), I

Re: [go-nuts] Generics - please provide real life problems

2020-12-24 Thread K. Alex Mills
On Thu, Dec 24, 2020, 1:18 AM Martin Hanson wrote: > I'm sorry, but this is not real life problems. This is exactly the problem > with this proposal. It's based on nothing but small theoretical examples. > Sorry, I don't understand. Here are some of the example applications which Ian mentions

Re: [go-nuts] Re: Generics, please go away!

2020-12-23 Thread K. Alex Mills
On Wed, Dec 23, 2020, 6:17 AM Martin Hanson wrote: > > After generics gets added, it's going to be something else next time, and > again and again. The list goes on and on about changes people want to > make to Go. Not real life problems, just so-called "nice to have". > > No, the added and

Re: [go-nuts] The GitHub Vet Project

2020-12-21 Thread K. Alex Mills
On Sun, Dec 20, 2020, 2:01 PM Jan Mercl <0xj...@gmail.com> wrote: > > I expressed my concerns at the issue tracker in 2017 when I still had > a Github account. That's no more the case, so I'll take the > opportunity to make a comment here. I still believe that the intent to > change the behavior

[go-nuts] The GitHub Vet Project

2020-12-20 Thread K. Alex Mills
your GitHub username and a brief outline of your experience with Go. It's my hope that this project can provide some data that can help to move Go forward. To that end, I'm also interested in any and all feedback and suggestions. Contributions are also welcome <https://github.com/github-vet/bots/issue

Re: [go-nuts] global goroutine data / thread local storage?

2020-09-23 Thread Alex Mills
But I tried compiling this program: https://github.com/davecheney/junk/tree/master/id and I cant get it to compile/run, the runtime.h file seems MIA -alex On Wed, Sep 23, 2020 at 6:02 PM Alex Mills wrote: > Not a joke, in terms of performance, if you access the goroutine id via >

Re: [go-nuts] global goroutine data / thread local storage?

2020-09-23 Thread Alex Mills
Not a joke, in terms of performance, if you access the goroutine id via the C library call? My only concern would be if goroutine id's were reused, if not it would work. On Wed, Sep 23, 2020 at 5:54 PM Ian Lance Taylor wrote: > On Wed, Sep 23, 2020 at 5:46 PM Alex Mills wr

Re: [go-nuts] global goroutine data / thread local storage?

2020-09-23 Thread Alex Mills
ref=spike-organic-signature&_ts=p4aw3> [image: > p4aw3] > > On September 24, 2020 at 0:17 GMT, Alex Mills > wrote: > > > Since by default all http requests coming to a go http server are on their > own goroutine, I am wondering if there is a way to have some sort of >

[go-nuts] global goroutine data / thread local storage?

2020-09-23 Thread Alex Mills
Since by default all http requests coming to a go http server are on their own goroutine, I am wondering if there is a way to have some sort of "global" variable that is *local* to a goroutine if that makes sense, something like this, where "gork" is the namespace for variables available

Re: [go-nuts] Re: How to import one field from package, etc

2020-09-23 Thread Alex Mills
It works temporarily, but then I have to manually update each file that imports + exports the methods, it won't "just work" with new versions of the library that gets imported, right? On Wed, Sep 23, 2020 at 11:59 AM Jason Phillips wrote: > Did you try your own suggestion? It seems to work

[go-nuts] Re: How to create UTC date without extra UTC string

2020-09-23 Thread Alex Mills
languages. On Wednesday, September 23, 2020 at 11:39:08 AM UTC-7 Alex Mills wrote: > I have this date string: > > "2020-09-23 18:31:41.015852841 + UTC" > > the above is generated via: > > > *time.Now().UTC().String()* > > my question is, how can I gener

[go-nuts] How to create UTC date without extra UTC string

2020-09-23 Thread Alex Mills
I have this date string: "2020-09-23 18:31:41.015852841 + UTC" the above is generated via: *time.Now().UTC().String()* my question is, how can I generate a date string like this: "2020-09-23 18:31:41.0158" and how can I then parse it? I dont need to indicate that it's UTC, I can

[go-nuts] How to import one field from package, etc

2020-09-23 Thread Alex Mills
Using node.js, we might have this: const z = new Z(); exports.z = z and then in another file we can import import {z} from '../z' with Golang, I am trying to do something similar: package log import Logger "github.com/foo/bar/logger" // create an instance var log = Logger.create() //

Re: [go-nuts] how to use replace directives in go.mod in dev but not prod

2020-09-22 Thread Alex Mills
i dont understand, is there a solution or just a proposal? On Mon, Sep 21, 2020, 23:03 Paul Jolly wrote: > I just replied. I think that https://github.com/golang/go/issues/26640 > covers this. > > On Tue, 22 Sep 2020 at 06:52, Alex Mills wrote: > > > > I put this ques

[go-nuts] how to use replace directives in go.mod in dev but not prod

2020-09-21 Thread Alex Mills
I put this question on the golang issue tracker on github: https://github.com/golang/go/issues/41546 I am sure it's been answered before but hard to search for..anyone know what the right approach is? I like how node.js / NPM solve it using symlinks personally. -- You received this message

Re: [go-nuts] How to clear current line in terminal

2020-09-19 Thread Alex Mills
anic-signature&_ts=owh4j> [image: > owh4j] > > On September 19, 2020 at 18:44 GMT, Alex Mills > wrote: > > > Using Node.js with several projects I can use these: > > const rl = require('readline'); > process.stdout.write('current line') > rl.

[go-nuts] How to clear current line in terminal

2020-09-19 Thread Alex Mills
Using Node.js with several projects I can use these: const rl = require('readline'); process.stdout.write('current line') rl.clearLine(process.stdout); rl.cursorTo(process.stdout, 0); this will clear the current line in the terminal, so I can achieve something like a status line, but I cannot

Re: [go-nuts] alloc vs totalalloc in memory

2020-09-11 Thread Alex Mills
The explanations I find online arent very clear to me :( On Thursday, September 10, 2020 at 6:40:34 PM UTC-7 Ian Lance Taylor wrote: > On Thu, Sep 10, 2020 at 4:39 PM Alexander Mills > wrote: > > > > I have this helper func to print memory usage (detect a memory leak?) > > > > > > func