Re: [go-nuts] Hello, world! - A technical overview of the software powering bgammon.org

2024-01-02 Thread Ian Davis
On Tue, 2 Jan 2024, at 2:39 AM, Trevor Slocum wrote: > I’ve just published a blog post about the software powering bgammon.org and > my experience creating it using free and open source tools: > > https://bgammon.org/blog/20240101-hello-world/ This was a great read, thank you. -- You received

Re: [go-nuts] Go routine context

2022-09-30 Thread Ian Davis
On Fri, 30 Sep 2022, at 3:32 PM, Robert Engels wrote: > Very interesting article came out recently. > https://www.infoq.com/articles/java-virtual-threads/ and it has implications > for the Go context discussion and the author makes a very good case as to why > using the thread local to hold the

Re: [go-nuts] Sets

2022-09-27 Thread Ian Davis
On Tue, 27 Sep 2022, at 6:57 PM, Robert Engels wrote: > The github set issue is impossible to follow without using github. > > Please simply define the interfaces. The implementations will follow. > You can have simple iterators, indexed iterators, map (key/value) > iterators, errorable

Re: [go-nuts] understanding interface conversions

2022-09-22 Thread Ian Davis
On Thu, 22 Sep 2022, at 11:27 PM, Rory Campbell-Lange wrote: I just wanted to respond to this part: > I suppose my question is (and forgive me if this is a terrifically > naive), how can one negotiate the go landscape of commonly used modules > to re-utilise, where possible, a more commonly

Re: [go-nuts] Library for printing a struct as a compiler recognized version

2022-08-15 Thread Ian Davis
Perhaps https://github.com/kortschak/utter might suit your needs? On Mon, 15 Aug 2022, at 4:07 PM, John wrote: > Hey axel, > > I recognize the problem space you are discussing. There are a couple > strategies I could implement to try and solve the problems. And I'm not 100% > sure you can

Re: [go-nuts] What goes wrong when embedding goroutines inside a for loop?

2022-02-17 Thread Ian Davis
On Thu, 17 Feb 2022, at 5:20 AM, Zhaoxun Yan wrote: > package main > import "fmt" > > func main() { > targetIndice := make([]int, 3) > targetIndice[0] = 5 > targetIndice[2] = 4 > > for i,n := range targetIndice{ > fmt.Printf("%d : %d \n", i, n) > } > > c

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-02-01 Thread Ian Davis
On Mon, 31 Jan 2022, at 8:33 PM, Uli Kunitz wrote: > Please have a look at golang.org/x/time/rate > . This package should solve your > problem. > > Here is an example with 10 events per second. > > func main() { >

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Ian Davis
On Fri, 24 Sep 2021, at 10:36 AM, 'Dan Kortschak' via golang-nuts wrote: > On Fri, 2021-09-24 at 10:22 +0100, Ian Davis wrote: >> I was responding to your statement that it doesn't appear to use >> exact match in preference. It does, as the example I gave >> demonstrated. It

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Ian Davis
On Fri, 24 Sep 2021, at 10:00 AM, 'Dan Kortschak' via golang-nuts wrote: > On Fri, 2021-09-24 at 09:55 +0100, Ian Davis wrote: >> On Fri, 24 Sep 2021, at 9:36 AM, 'Dan Kortschak' via golang-nuts >> wrote: >> > On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: >&g

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Ian Davis
On Fri, 24 Sep 2021, at 9:36 AM, 'Dan Kortschak' via golang-nuts wrote: > On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: >> On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler wrote: >> > The documentation says it prefers exact match over case- >> > insensitive, but example 3

Re: [go-nuts] Re: [security] Go 1.17.1 and Go 1.16.8 are released

2021-09-10 Thread Ian Davis
On Fri, 10 Sep 2021, at 11:11 AM, Jérôme LAFORGE wrote: > Hello all, > For testing purpose, how can I install Go 1.16.8 with Go 1.17? > > ``` > $go version > go version go1.17 linux/amd64 > > $go get golang.org/dl/go1.16.8 > go get: installing executables with 'go get' in module mode is

Re: [go-nuts] Managing perpetually running goroutines

2021-08-30 Thread Ian Davis
On Sun, 29 Aug 2021, at 10:45 PM, sansaid wrote: > Hello, > > Does anybody know of some reference code or common patterns I can use to keep > track of worker goroutines? For context, I want a user to be able to issue a > "stop" command using a CLI tool which will prompt my server to gracefully

[go-nuts] Are receiver copies atomic?

2021-06-08 Thread Ian Davis
This question came to me while reading the recent thread titled "Knowing from documentation whether an interface is holding a pointer or a struct?" When a method with a non-pointer receiver is called, is the copy made atomically? My intuition says it must be but perhaps someone else can confirm

Re: [go-nuts] Re: Table-driven benchmarks defeat inlining

2021-06-07 Thread Ian Davis
opCountNearlySimple-4 5.69ns ± 0% > $ > > Peter > > > On Monday, June 7, 2021 at 6:14:05 AM UTC-4 Ian Davis wrote: >> __ >> Would it be feasible for the Go tool to disable inlining and deadcode >> elimination of code within the bodies of Ben

Re: [go-nuts] Re: Table-driven benchmarks defeat inlining

2021-06-07 Thread Ian Davis
Would it be feasible for the Go tool to disable inlining and deadcode elimination of code within the bodies of Benchmarks and Tests? Not the code under test of course. It could be as crude as disabling these optimizations for files in _test.go files. On Sun, 6 Jun 2021, at 1:33 PM, Paul S.

Re: [go-nuts] time.ParseInLocation fails silently

2021-05-28 Thread Ian Davis
On Fri, 28 May 2021, at 11:32 AM, NieomylnieJa wrote: > But the docs state something different: > > // ParseInLocation is like Parse but differs in two important ways. > // First, in the absence of time zone information, Parse interprets a time as > UTC; > // ParseInLocation interprets the time

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-04-29 Thread Ian Davis
On Thu, 29 Apr 2021, at 3:09 PM, robert engels wrote: > I will give you the pseudo code: > > { // step #1 do select on both >select high >select low > } > > if high read: >return high > else: >// we read a low so do a high poll >{ >select high: >default: >

Re: [go-nuts] Error handling

2021-02-21 Thread Ian Davis
On Sun, 21 Feb 2021, at 5:23 PM, robert engels wrote: > Can someone please explain the benefit of ‘error return’ over ‘checked > exceptions’ ? I have made the point a few times and it goes to crickets > - I have to believe that is because there is none, or it is difficult > to communicate. >

Re: [go-nuts] A value saved in an interface{} field in a struct not usable in func with interace{} arg

2021-01-12 Thread Ian Davis
wer version, or > something...? > > murf > On Tuesday, January 12, 2021 at 7:52:40 AM UTC-7 Ian Davis wrote: >> __ >> Note the error says that val was nil, so your type assertion will panic. You >> can read more about how to make type assertions that report success or >

Re: [go-nuts] A value saved in an interface{} field in a struct not usable in func with interace{} arg

2021-01-12 Thread Ian Davis
on? > > I don't know what to think. > > BTW, I'm on ubuntu 20.04, and the version of go is 1.13. > > murf > > On Monday, January 11, 2021 at 10:45:29 AM UTC-7 Ian Davis wrote: >> __ >> In genBox your code is saying that val contains a pointer to interface{}. In >>

Re: [go-nuts] A value saved in an interface{} field in a struct not usable in func with interace{} arg

2021-01-11 Thread Ian Davis
In genBox your code is saying that val contains a pointer to interface{}. In other words its an interface{} that contains a *interface{}. That is a weird but valid construct. I suggest you dereference it and see what the contained interface holds. Something like: valDeref :=

Re: [go-nuts] How to set the "godebug" environment variable from the go file?

2020-12-18 Thread Ian Davis
On Fri, 18 Dec 2020, at 4:18 PM, Sean wrote: > My previous reply was sent to Ian. Sorry. > The point I don't understand is "os.Args". > I think the parameter here is the name of my program. So like "program.exe". > Args is a variable in the os package. Go ensures that the the first element

Re: [go-nuts] How to plug git version when using "go get" to fetch a cli?

2020-11-25 Thread Ian Davis
The version is really a property of the code (and binary) not the repository. I think it's better to put the version in the code that is committed. This is the approach taken by packages such as protobuf

Re: [go-nuts] Limiting the max heap size of a Go process

2020-11-25 Thread Ian Davis
On Wed, 25 Nov 2020, at 12:44 PM, Viktor Kojouharov wrote: > > Hi, > > Is there a way to set a hard limit on the max heap size a process is allowed > to consume, from within it? > It's almost never a problem for a process to consume as much memory as is > available, however, I've ran into

Re: [go-nuts] Re: Getting syntax-error on from assignment in if statements

2020-10-15 Thread Ian Davis
On Thu, 15 Oct 2020, at 4:16 PM, Brian Candler wrote: > It looks like a parsing ambiguity to me. The error suggests that the > open-brace is being treated as the start of the body of the if-statement, i.e. > > if v := T { > }.F() > > Try changing it to > > if v == T{}.F(); v {} > > and

Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Ian Davis
On Wed, 19 Aug 2020, at 12:02 PM, Ian Davis wrote: > > > On Wed, 19 Aug 2020, at 11:54 AM, Brian Candler wrote: >> Or another thought - perhaps you are looking for *adjacent* repeats only? >> >> In that case strings.Count doesn't help because it counts all occurre

Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Ian Davis
On Wed, 19 Aug 2020, at 11:54 AM, Brian Candler wrote: > Or another thought - perhaps you are looking for *adjacent* repeats only? > > In that case strings.Count doesn't help because it counts all occurrences, > not just adjacent ones. I suspect the OP is looking for the longest repeating

Re: [go-nuts] Sum type experiment

2020-08-11 Thread Ian Davis
On Tue, 11 Aug 2020, at 3:38 PM, Sina Siadat wrote: > Hi golang-dev :) > > I was wondering what would be an idiomatic Go way > to implement a basic sum type in Go. After several > iterations I came up with 2 approaches I will share here. You may be interested in the discussions on

Re: [go-nuts] Go 2 review process

2020-07-19 Thread Ian Davis
On Sun, 19 Jul 2020, at 2:08 AM, Ian Lance Taylor wrote: > On Sat, Jul 18, 2020 at 12:19 AM Tyler Compton wrote: > > > > I'm beginning to think that community members (like myself) can't > > reasonably be expected to put in the necessary effort to champion a sizable > > language change. I think

Re: [go-nuts] the go archive size must be smaller?

2020-07-17 Thread Ian Davis
Note that progress for reducing binary size is tracked under this issue: https://github.com/golang/go/issues/6853 -- 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] Clean shutdown when blocked on I/O

2020-07-06 Thread Ian Davis
Can you write your own ContextReader that checks ctx.Done in its Read method? On Mon, 6 Jul 2020, at 2:40 PM, Brian Candler wrote: > I am looking for the safe way to do a clean shutdown when blocked on I/O. > Here is a basic example: > > package main > > import ( > "encoding/json" > "fmt" >

Re: [go-nuts] Is there +v Stringer interface?

2020-06-24 Thread Ian Davis
fmt.Formatter is woefully under documented. The second argument (called c in the interface definition) is the verb, i.e. 's', 'v', 'd' etc. The first argument provides a state interface with functions to allow you to emit the format of your type. The Flag function on this interface lets you

Re: [go-nuts] url.QueryEscape unexpectedly slow

2020-05-25 Thread Ian Davis
Don't use a byte for your loops, use an int. When your loop reaches 255 it is incremented to 0 which is still <= 255 so your loop never terminates. On Mon, 25 May 2020, at 10:54 PM, Liam wrote: > I would expect this to complete pretty quickly, but after 40 minutes (on > 1.13, linux/amd64), it

Re: [go-nuts] Re: Go mindshare is low & ~flat, per Google Trends

2020-01-16 Thread Ian Davis
If the purpose of adding "killer features" is just to make Go more popular then I'm completely against it. That doesn't seem like a sustainable way of growing and retaining a community, who may just move onto the next killer feature in another language. I'm not even sure that explicitly growing

Re: [go-nuts] Language spec question: why is k, v := k, v allowed in a for loop with range?

2020-01-12 Thread Ian Davis
The range clause introduces a new scope. See this version of your second example: https://play.golang.org/p/UXI_w6B4DW5 -- Ian On Sun, 12 Jan 2020, at 8:09 AM, Silvan Jegen wrote: > Hi fellow gophers > > The following code compiles > > > package main > > import ( > "fmt" > ) > > func

Re: [go-nuts] Locking goroutine to "main" thread

2019-12-17 Thread Ian Davis
On Sat, 14 Dec 2019, at 7:51 PM, bucha...@gmail.com wrote: > If I understand correctly, that would prevent me from starting any other > goroutines. The following program deadlocks: I doesn't prevent you starting other goroutines but you need to ensure that all calls to the OpenGL context are

Re: [go-nuts] How to mock structs with interdependent interface methods?

2019-12-13 Thread Ian Davis
On Thu, 12 Dec 2019, at 10:27 PM, karthik3...@gmail.com wrote: > Specifically, I couldn't find how to partially mock the `struct`. Most > suggestions revolve around breaking such `struct`s but in this case, the > `struct` is already at its bare minimum. It seems like a fair ask to not > break

Re: [go-nuts] Inconsistent rounding with float printf ?

2019-12-06 Thread Ian Davis
On Fri, 6 Dec 2019, at 9:25 AM, Christophe Meessen wrote: > I have noticed that printf performs an apparently inconsistent rounding of > floating point values. > > I divide a big number by 1000 and printf the resulting value with "%.1f". > Here is the code: https://play.golang.org/p/e7dD3c6IHq2

Re: [go-nuts] Re: [golang-dev] go.dev is live!

2019-11-14 Thread Ian Davis
On Thu, 14 Nov 2019, at 4:54 AM, Dan Kortschak wrote: > Hi, > > It looks like license detection needs work. > > See https://pkg.go.dev/gonum.org/v1/gonum?tab=overview and note it has > a BSD 3 clause, as shown by GitHub's assessment (just above the "Clone > or download" button) at

Re: [go-nuts] Forking gotk3 not working?

2019-09-25 Thread Ian Davis
On Tue, 24 Sep 2019, at 11:02 AM, erich.r...@gmail.com wrote: > Hi! This is perhaps more a question about git than Go but must have something > to do with go get, too. I tried to fork gotk3 from github on the web page > (using Fork button), because I need to merge some important 3rd party pull

Re: [go-nuts] Cannot find libraries at go.pedge.io by Peter Edge

2019-09-25 Thread Ian Davis
On Tue, 24 Sep 2019, at 10:48 PM, Craig Rodrigues wrote: > I have a package where the dependencies were vendored in a few years ago > using govendor. > > I am trying to convert the vendor tree from govendor to go modules. > > I a having problems finding libraries written by Peter Edge, > which

Re: [go-nuts] GO Mod (modules) for dummies. Please help.

2019-09-23 Thread Ian Davis
Hi, On Mon, 23 Sep 2019, at 11:04 AM, sdd.dav...@gmail.com wrote: > > If I have a reasonably large and complex (pet) project with local packages in > it. I like to split my project in to small units with 'namespaces' to keep it > manageable. These are NOT reusable components until I decide

Re: [go-nuts] sync.Mutex encounter large performance drop when goroutine contention more than 3400

2019-08-20 Thread Ian Davis
On Tue, 20 Aug 2019, at 9:33 AM, changkun wrote: > Hi Robert, > > Thanks for your explanation. But how could I "logged the number of operations > done per Go routine", which particular debug settings you referring to? > It is reasonable that sync.Mutex rely on runtime scheduler but channels do

Re: [go-nuts] Re: mutual exclusion algorithm of Dijkstra - strange behaviour

2019-08-16 Thread Ian Davis
On Fri, 16 Aug 2019, at 7:09 PM, dr.ch.mau...@gmail.com wrote: > Dear Community and dear Go-developers, > > Meanwhile it is clear why things do not work: > The Go-Scheduler is unable to allow to switch to another goroutine in > busy-waiting-loops - > the only possibility to get around that

Re: [go-nuts] RFC for opt-in streaming support in encoding/json package

2019-08-09 Thread Ian Davis
On Fri, 9 Aug 2019, at 3:33 PM, Jonathan Hall wrote: > *I debated posting here, or straight to GitHub. If that's the better place, I > can move the thread there. * I have long wanted proper streaming support in > the `encoding/json` library. Lately I’ve been doing some digging to > understand

Re: [go-nuts] Re: `on err` alternative to `try()` has traction...?

2019-07-09 Thread Ian Davis
On Tue, 9 Jul 2019, at 11:43 AM, Nicolas Grilly wrote: > >> So why complicate the language with a new keyword which has really no >> purpose. > > As mentioned in the proposal, try is not a new keyword, it's just a new > built-in function. It's quite a bit more than a just new function since

Re: [go-nuts] A proof-of-concept implementation of my generics proposal for Go

2019-06-27 Thread Ian Davis
Syntactically this looks very good. I have read your gist but I'd like to see this as a proposal in the Go issue tracker. Ian On Thu, 27 Jun 2019, at 3:29 PM, Michal Strba wrote: > Hey everybody! > > A few weeks ago, I posted about my proposal for generics in Go 2. You can > find it here. >

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-11 Thread Ian Davis
Yes, I wrote minimum when I meant to write maximum! Sorry for the confusion. On Tue, 11 Jun 2019, at 3:37 PM, t hepudds wrote: > As far as I understand, it is not a minimum version of the language. > > Also, a key point that is easy to miss is that the language version is > distinct from

Re: [go-nuts] how to prevent go1.13 go directive being written in an go directive-free go.mod?

2019-06-11 Thread Ian Davis
https://golang.org/cmd/go/#hdr-The_go_mod_file documents the go directive as the "expected language version". It seems it would be better described there as the "minimum language version". On Tue, 11 Jun 2019, at 2:43 PM, Ian Lance Taylor wrote: > On Tue, Jun 11, 2019 at 6:40 AM Ian Lance

Re: [go-nuts] why add the useless function in interface?

2019-03-26 Thread Ian Davis
On Tue, 26 Mar 2019, at 12:37 PM, XiaoBing Jiang wrote: > Hi, all: > > in src/cmd/compile/internal/syntax/nodes.go, why need the aNode() function in > the interface? > > type Node interface { > // Pos() returns the position associated with the node as follows: > // 1) The position of a node

Re: [go-nuts] Go modules do not respect vendor folder of dependencies (is this by design?)

2019-02-10 Thread Ian Davis
On Sun, 10 Feb 2019, at 12:03 AM, s...@pion.ly wrote: > * I have a project 'A' that is importing 'B' > * 'B' uses a vendor folder, if you delete the vendor folder the project does > not compile. > * With `GO111MODULE=on` I am unable to project 'A'. It tries to pull the > latest of 'B', and

Re: [go-nuts] What does a deadlock mean in golang?

2019-01-29 Thread Ian Davis
It's because the goroutine executing the main function blocks until the last channel send completes. But since you don't have another goroutine receiving from the channel the program cannot continue and remains in a blocked state. This is the cause of the deadlock. On Tue, 29 Jan 2019, at 8:55

Re: [go-nuts] Using "er" and "able" for interfaces

2019-01-18 Thread Ian Davis
On Thu, 17 Jan 2019, at 7:48 PM, Jakob Borg wrote: > On 16 Jan 2019, at 15:42, Victor Giordano wrote: > >> >> As far i can get to understand the english language (i'm not a native >> speaker), the "er" seems to denotes or describe things in a more "active >> way" (the thing that they

Re: [go-nuts] Unable to delete multiple records (multiple ids) on hitting endpoint

2019-01-17 Thread Ian Davis
On Thu, 17 Jan 2019, at 8:13 AM, aniruddha.dwiv...@nytimes.com wrote: > Hi I am using NYT's Marvin framework which internally uses gorilla mux. I am > able to delete single record when I pass single id as json object in request > body using postman but I don't know how to handle array of json

Re: [go-nuts] Using "er" and "able" for interfaces

2019-01-16 Thread Ian Davis
On Wed, 16 Jan 2019, at 2:42 PM, Victor Giordano wrote: > As far i can get to understand the english language (i'm not a native > speaker), the "er" seems to denotes or describe things in a more "active way" > (the thing that they actually do by itself), and the "able" describes things > in a

[go-nuts] Missing docker hub images for Go 1.11.4?

2018-12-18 Thread Ian Davis
Is there a problem with the docker hub build at the moment? Currently only Go 1.11.3 is available there: https://hub.docker.com/_/golang/ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] Json and value

2018-12-12 Thread Ian Davis
On Wed, 12 Dec 2018, at 9:46 AM, olivier.gale...@gmail.com wrote: > i have the same response > [{"id": > 62,"nom":"TEST","URI":"http://192.168.0.31/param/","IP":"192.168.0.31","MacAdress":"DE:AD:BE:EF:FE:ED","created_at":"2018- > 12-06T20:44:57.131380+01:00","update_at":"2018-12- >

Re: [go-nuts] Json and value

2018-12-12 Thread Ian Davis
On Wed, 12 Dec 2018, at 6:03 AM, olivier.gale...@gmail.com wrote: > Hello, > > I trie to get value from api request > i have this response > [{"id": > 62,"nom":"TEST","URI":"http://192.168.0.31/param/","IP":"192.168.0.31","MacAdress":"DE:AD:BE:EF:FE:ED","created_at":"2018- >

Re: [go-nuts] Re: Strange glog.V(level) behavior in go.1.11.2 ?

2018-12-08 Thread Ian Davis
The best thing to do would be to make a self contained example that reproduces it and file an issue at https://github.com/golang/go/issues On Sat, 8 Dec 2018, at 8:49 AM, Jan wrote: > I still haven't solved the issue (I just keep that odd line _ = ) > in the middle of the code.> > But I quickly

Re: [go-nuts] Unable to view go-review.googlesource.com on Firefox 60.x

2018-11-16 Thread Ian Davis
On Fri, 16 Nov 2018, at 6:05 PM, Wagner Riffel wrote: > I'm either on 60.3 under linux and it's working fine. OK thanks, it must be something on my system -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Unable to view go-review.googlesource.com on Firefox 60.x

2018-11-16 Thread Ian Davis
Hi all, Since upgrading to Firefox 60.3 on Linux I am unable to view any pages on https://go-review.googlesource.com/ and I wondered if anyone else was seeing this problem or if it's an issue with my setup? Chromium renders the pages fine. When I view source with Firefox I see the following:

Re: [go-nuts] Why doesn't this benchmark test end?

2018-10-22 Thread Ian Davis
On Mon, 22 Oct 2018, at 4:36 PM, Sathish VJ wrote: > So, I also tried with > *go test -v -bench=. -test.benchtime=0.1s * > and that does complete. > > But is the implication that StopTimer/StartTimer is too costly to use > even for this simple benchmark? See

Re: [go-nuts] Variadic functions using ...interface{}

2018-10-21 Thread Ian Davis
On Sun, 21 Oct 2018, at 10:52 PM, Justin Israel wrote: > I was getting an error trying to pass a []string to this elasticsearch > API ctor:> > https://github.com/olivere/elastic/blob/v6.2.11/search_queries_terms_set.go#L26> > > func NewTermsSetQuery(name string, values ...interface{}) >

Re: [go-nuts] `go mod download -json` does not product valid json?

2018-10-06 Thread Ian Davis
On Sat, 6 Oct 2018, at 3:07 PM, 'kalekold' via golang-nuts wrote: > `go mod download -json` does not product valid json? Is this a known > issue or am I missing something? Do you have an example that shows the invalid json? -- You received this message because you are subscribed to the Google

Re: [go-nuts] Huge map[string]*Object and GC where *Object is from sync.Pool

2018-09-27 Thread Ian Davis
On Thu, 27 Sep 2018, at 3:06 PM, Peter Mogensen wrote: > > > On 09/27/2018 03:58 PM, Robert Engels wrote: > > It wasn’t necessarily a warning to you :) > > > > It comes from the days of GC bashing in Java and so everyone tried to > > manually write garbage free programs using pools and it had

Re: [go-nuts] Huge map[string]*Object and GC where *Object is from sync.Pool

2018-09-27 Thread Ian Davis
On Thu, 27 Sep 2018, at 2:04 PM, Peter Mogensen wrote: > > Of course... it requires that you handle any collisions in hashing the > string key to an int yourself, but wrt. the value I curious if anyone > can see issued with just storing a uintptr instead of the pointer for > sync.Pool managed

Re: [go-nuts] Re: Why google doesnt make jdbc like library for go?

2018-09-21 Thread Ian Davis
On Fri, 21 Sep 2018, at 3:36 AM, ascarra...@gmail.com wrote: > He has a valid point. Most of the enterprise applications uses Oracle > DB. I for one is looking for an oracle driver similar to what JDBC > does (a simple to use, no separate installation needed). All of Go > oracle drivers available

Re: [go-nuts] Announcing a Fyne GUI toolkit

2018-09-14 Thread Ian Davis
On Fri, 14 Sep 2018, at 6:02 PM, Andrew Williams wrote: > > It's now well into development and ready for people to get involved. > There is a long way to go but it feels like a solid base.> Instructions for > getting started, if you need them, are at >

Re: [go-nuts] Generics - Why contracts?

2018-09-11 Thread Ian Davis
On Tue, 11 Sep 2018, at 3:23 PM, Jeff wrote: > TLDR; So why contracts and not templates or something else? Is there > a benefit to contracts that I don't appreciate (very likely, cause I > don't understand them)? Are there issues with a template approach? > If this has been addressed elsewhere,

Re: [go-nuts] Setting font in draw2d

2018-09-11 Thread Ian Davis
On Tue, 11 Sep 2018, at 3:01 PM, viktor.oge...@gmail.com wrote: > Hi, > > I am struggling to load and use custom fonts from ttf files in draw2d > (used since I need rotated text).> > To illustrate: https://play.golang.org/p/6-rswetZOr8 give the output:> > 2018/09/11 15:52:43 open

Re: [go-nuts] How to deal with binaries compilation with go modules enabled?

2018-08-30 Thread Ian Davis
On Thu, 30 Aug 2018, at 3:37 PM, Denis Cheremisov wrote: > Hi! > With Go 1.10 and earlier one can install binaries via regular `go > get`, `go get golang.org/x/tools/cmd/goimports` for instance.> It doesn't > work with Go modules enabled: > > $ go get golang.org/x/tools/cmd/goimports > go:

Re: [go-nuts] How to find other packages using this package?

2018-08-17 Thread Ian Davis
On Fri, 17 Aug 2018, at 5:08 PM, Tad Vizbaras wrote: > I have a package. Let say a/b/c. How to find what are other packages > in my GOPATH using it?> > I am basically trying to clean up GOPATH from all unused packages > installed and downloaded over the years.> Finding "dead" packages in GOPATH.

Re: [go-nuts] Http/net - post and decode json data part

2018-08-14 Thread Ian Davis
On Tue, 14 Aug 2018, at 12:44 PM, nicolas_boiteux via golang-nuts wrote:> the raw of response.body is this > > > { "args": {}, "data": > "{\"firstname\":\"Nic\",\"lastname\":\"Raboy\"}", "files": {}, > "form": {}, "headers": {"Accept-Encoding": "gzip", > "Connection": "close",

Re: [go-nuts] Http/net - post and decode json data part

2018-08-14 Thread Ian Davis
On Tue, 14 Aug 2018, at 11:19 AM, nicolas_boiteux via golang-nuts wrote:> Hello > > I need some assistance to decode a json content > > I tried to use only usefull code to do it but don't success to > retrieve the data part of the json result.> > > var user struct {Firstname string

Re: [go-nuts] The &(*x) idiom for copying.

2018-03-28 Thread Ian Davis
On Wed, 28 Mar 2018, at 5:21 PM, thwd wrote: > https://play.golang.org/p/pjyoPX99Zr1 > > Taking the address of an explicit dereference has different behavior > than implicitly dereferencing and taking address.> > Is this the desired behavior? It surprised me. I think the naming of your

Re: [go-nuts] A Go Const suggester?

2018-03-28 Thread Ian Davis
On Wed, 28 Mar 2018, at 8:32 AM, Patrik Iselind wrote: > Is there such a tool that can go through a GoLang code base and > suggest values that might be a good idea to convert into constants?> > If a value (for example an int or a string, but excluding values that > are already constants) is hard

Re: [go-nuts] what is the out put of this code and why?

2018-02-01 Thread Ian Davis
If it compiled (there are syntax errors) then I'd expect it to print each of the numbers 0..99 doubled, followed by a repeat of the last printed value. Each iteration of the second loop you set y = x[i]+i What are you trying to achieve? On Thu, 1 Feb 2018, at 9:43 AM, Ganesh kumar wrote: >

Re: [go-nuts] Re: Table Driven Test (TDT) and log only failed test case

2018-01-30 Thread Ian Davis
Define a logging interface in your main package, then pass an implementation of the interface in your test that forwards writes to t.Logf On Tue, 30 Jan 2018, at 2:11 PM, Jérôme LAFORGE wrote: > No, it is not possible to use t.Log within the code you want to test.> The > function IsBuggyEven is

Re: [go-nuts] glog + vendor = "flag redefined: log_dir"?

2018-01-30 Thread Ian Davis
On Tue, 30 Jan 2018, at 7:59 AM, porridge via golang-nuts wrote: > I admit I'm somewhat new to Golang, how do I solve this problem? > My program uses two libraries, both of which have > github.com/golang/glog in their /vendor/ directories.> This results in a > panic at runtime, apparently because

Re: [go-nuts] "type MyByte byte", then how to convert []MyByte to []byte so that I can use bytes.Xyz functions for []MyByte?

2018-01-24 Thread Ian Davis
A loop is the usual way. On Wed, 24 Jan 2018, at 12:57 PM, d...@veryhaha.com wrote: > except unsafe ways. > > -- > 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

Re: [go-nuts] Underlying arrays and their slices passed to functions

2018-01-05 Thread Ian Davis
On Thu, 4 Jan 2018, at 6:55 PM, Frank Davidson wrote: > Thanks!!! Very helpful blog post!! > > So, in proc, the slice header is copied, then an entirely new array is > created - []byte{5,6,7,8} - and the slice header copy is set to point > at that new array, and then discarded, whereas in proc 2,

Re: [go-nuts] Matrix Operation

2018-01-02 Thread Ian Davis
Try gonum https://godoc.org/gonum.org/v1/gonum/mat On Tue, 2 Jan 2018, at 10:58 AM, meher akshay wrote: > Hi everyone, > > I want to find the eigen vectors and values of a matrix in golang. > Please help me as I am not able to do it using the provided docs > > Thanks > > -- > You

Re: [go-nuts] Is the result right or not?

2017-12-06 Thread Ian Davis
You can see your error if you initialise i to -1 before the loop: v[i] is evaluated before i is incremented. On Wed, 6 Dec 2017, at 02:26 PM, T L wrote: > > package main > > import "fmt" > > func main() { > var i int > var x = []int{3, 5, 7} > var y = make([]int, 3) > for i, y[i] =

Re: [go-nuts] Urgent: race condition with ticker channels

2017-11-06 Thread Ian Davis
On Mon, 6 Nov 2017, at 12:14 PM, arunabh.ar...@gmail.com wrote: > Hi, > > I am fairly new to Golang, so please excuse if this is a silly > question. I could not find any answers on the web.> > Code portion A: > > rf.mu.Lock() > rf.electionTicker = time.NewTicker(rf.currentTimeout) >

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Ian Davis
On Fri, 20 Oct 2017, at 06:34 AM, Jan Mercl wrote: > On Fri, Oct 20, 2017 at 7:25 AM Feby Tanzil > wrote:> > > Which is better & preferable in Go? > > Depends on size of T. How does that affect the size of []T or []*T ? Ian -- You received this message because you are

Re: [go-nuts] Debugging a mutex/scheduling issue

2017-10-16 Thread Ian Davis
This sounds like https://github.com/golang/go/issues/13086 On Mon, 16 Oct 2017, at 09:01 PM, Caleb Spare wrote: > I have a server which is doing log processing and I'm trying to > improve throughput. The bottleneck is access to a shared resource > protected by a sync.Mutex. The issue is that even

Re: [go-nuts] Why can't I call a pointer-receiver method on a temperary but addressable struct literal?

2017-10-13 Thread Ian Davis
On Fri, 13 Oct 2017, at 02:02 PM, Ian Davis wrote: > On Fri, 13 Oct 2017, at 01:41 PM, Cholerae Hu wrote: >> https://golang.org/ref/spec#Calls >>> If x is addressable[1] and 's method set contains m, x.m() is >>> shorthand for ().m()>> >> https:

Re: [go-nuts] Strange behavior when dealing with certain emojis

2017-10-11 Thread Ian Davis
On Wed, 11 Oct 2017, at 11:16 AM, Gianguido Sorà wrote: > Uhm, so the Replacer sees it as two separate entities, and replaces > the part of the composite that matches one of the cases. Sort of. The emoji is really just the "\xE2\x83\xA3" part (or "\U20e3") which puts a keycap symbol around

Re: [go-nuts] Strange behavior when dealing with certain emojis

2017-10-11 Thread Ian Davis
On Wed, 11 Oct 2017, at 10:33 AM, Ian Davis wrote: > > On Wed, 11 Oct 2017, at 09:57 AM, Gianguido Sorà wrote: >> >> I'm writing a small utility which uses a strings.Replacer to process >> some substitutions in some strings; these strings contains UTF-8 >>

Re: [go-nuts] Strange behavior when dealing with certain emojis

2017-10-11 Thread Ian Davis
On Wed, 11 Oct 2017, at 09:57 AM, Gianguido Sorà wrote: > > I'm writing a small utility which uses a strings.Replacer to process > some substitutions in some strings; these strings contains UTF-8 > characters as well as emojis.> > Here you can find a playground with an example: >

Re: [go-nuts] "defer go"

2017-10-10 Thread Ian Davis
On Tue, 10 Oct 2017, at 02:27 PM, Shawn Milochik wrote: > On Tue, Oct 10, 2017 at 9:13 AM, Scott Cotton labs.com> wrote:>> Hi all, >> >> 1. "defer go" extend defers to work on goroutine exit with >>mechanism just like defer, but if we say "defer go f()">> instead of >> "defer

Re: [go-nuts] binary.Read()

2017-10-05 Thread Ian Davis
On Thu, 5 Oct 2017, at 08:58 AM, Johan terryn wrote: > In following code: > > type JPGFile struct { > Exif_SOI [2]byte Exif } type Exif struct { APP1Marker [2]byte > APP1DataSize uint16 ExifHeader [6]byte TIFFHeader[6]byte }> func > ReadFile(filename string) (JPGFile, error) {

Re: [go-nuts] Parsing a CSV column with partially double-quotes in it

2017-09-29 Thread Ian Davis
Try setting r.LazyQuotes=true On Thu, 28 Sep 2017, at 09:56 PM, Lantos István wrote: > > I want to parse the following CSV structure. The column separators > are tabs:> > *package main* > > *import (* > *"encoding/csv"* > *"fmt"* > *"log"* > *"strings"* > *)* > > *func main()

Re: [go-nuts] public interface with private method: totally dubious ? In which case is it useful ?

2017-09-04 Thread Ian Davis
It's a pattern that can be used to prevent external implementations of the interface. Another example is the text/template package in the standard library: https://github.com/golang/go/blob/master/src/text/template/parse/node.go#L21 On Mon, 4 Sep 2017, at 01:21 PM, mhhc...@gmail.com wrote: > hi,

Re: [go-nuts] go1.8 and json.NewDecoder(resp.Body)

2017-05-23 Thread Ian Davis
On Tue, 23 May 2017, at 01:33 PM, John Shahid wrote: > The only way I can think of to fix this is either using > ioutil.ReadAll(resp.Body) combined with json.Unmarshal, or use > json.NewDecoder() followed by ioutil.ReadAll and discard the result.> What do > you all think ? > I noticed just

Re: [go-nuts] Re: Problem with checking errors when testing

2017-05-21 Thread Ian Davis
On Sun, 21 May 2017, at 05:32 PM, breamore...@gmail.com wrote: > > On Sunday, May 21, 2017 at 11:52:41 AM UTC+1, Tamás Gulácsi wrote: >> A nil does not have type >> A nil interface may have. See >> http://spf13.com/post/when-nil-is-not-nil/>> Why don't you use type switch? > > I've no idea

Re: [go-nuts] Why no return statement for *timerCtx in func parentCancelCtx(context.go)

2017-05-17 Thread Ian Davis
On Wed, 17 May 2017, at 01:40 PM, Guohua Ouyang wrote: > I was confusing when I read the lines #L279-#L280 > https://github.com/golang/go/blob/master/src/context/context.go#L279 it will loop with the new value of parent > -- > You received this message because you are subscribed to the Google

Re: [go-nuts] Re: Do I need to unset variables in a for loop?

2017-05-09 Thread Ian Davis
On Tue, 9 May 2017, at 05:07 PM, Jesper Louis Andersen wrote: >> >> I don't believe this is helpful to the questioner who was simply >> explaining their understanding.>> > > A reference to cargo cults is useful insofar one should study why > something happens rather than copying a hearsay. On

Re: [go-nuts] Re: Do I need to unset variables in a for loop?

2017-05-09 Thread Ian Davis
On Tue, 9 May 2017, at 04:31 PM, Pierre Durand wrote: >> I "believe" in PHP a for loop keeps the variable in memory until the >> end of the script and if you want to remove the variable from memory >> you need to unset the variable to help conserve memory.> >

Re: [go-nuts] Re: suggest: improve go gen intergration for non core code ?

2017-05-09 Thread Ian Davis
On Tue, 9 May 2017, at 12:12 PM, mhhc...@gmail.com wrote: > Maybe that could be a simple go sub command: > > go gun [...packages] > > gen+run=>gun > > Sure i could do on my end, it won t be adopted so ... useless. Usually go generate is intended to be run once and the results committed to

  1   2   >