[go-nuts] Equivalent Interfaces - why does this fail to compile?

2021-05-23 Thread Amnon
See https://play.golang.org/p/5x9JrD55WKc The interfaces aer and ber look equivalent. Both contain a function which returns nothing called m1 and a function which returns another an instance of the interface m2. If we comment out m2, then the code will compile. But otherwise we get an error: ./p

Re: [go-nuts] How to cast a multi-value?

2021-05-18 Thread Amnon
My understanding was that a string had a pointer and a length, whereas a slice had a pointer and a length and a capacity. https://golang.org/src/reflect/value.go?s=59515:59567#L1973 On Tuesday, 18 May 2021 at 20:32:39 UTC+1 Brian Candler wrote: > Assigning a string value to another variable doe

[go-nuts] Re: Map to struct and vice versa

2021-05-17 Thread Amnon
https://programmersought.com/article/93641771999/ On Monday, 17 May 2021 at 10:26:14 UTC+1 nick@gmail.com wrote: > Is there an easy way to go from a map to a struct and vice versa? e.g. > going from: > m := map[string]interface{}{"a": "x", "b": 5} > > to an instance of: > type T struct

[go-nuts] Re: Reflect on Rust for Android and Linux kernel support

2021-05-09 Thread Amnon
n order to cover more niche areas might not improve the language. - amnon On Sunday, 9 May 2021 at 08:40:52 UTC+1 Uli Kunitz wrote: > There are multiple differences that make Rust a better replacement for > C/C++ code than Go: > > * Go requires a garbage collector and its own sche

[go-nuts] Re: How to merge two Unstructured objects type ?

2021-05-02 Thread Amnon
tation > > I am looking for something like the following > func mergeObjects(obj1 *uns.Unstructured, obj2 *uns.Unstructured) > (*uns.Unstructred, error) { > > } > > Thanks > On Sunday, May 2, 2021 at 1:35:06 PM UTC-4 Amnon wrote: > >> I am not sure what you mean

[go-nuts] Re: How to merge two Unstructured objects type ?

2021-05-02 Thread Amnon
I am not sure what you mean by an unstructured object. So probably best if you show us the code where they are defined. On Sunday, 2 May 2021 at 16:37:12 UTC+1 mmahmo...@gmail.com wrote: > Hi All: > > I am using two unstructured objects to represent two different > ConfigMaps, of the same every

Re: [go-nuts] Re: How to do vdso calls in my own code?

2021-04-28 Thread Amnon
Why not use the TSC timer for your timings, and convert TSC cycle times into durations during post-run analysis? On Thursday, 29 April 2021 at 04:04:58 UTC+1 Pure White wrote: > Hello, > We are doing heavily tracing, and for each func we need to get the time, > so that’s why I’d like to optim

Re: [go-nuts] Re: How to do vdso calls in my own code?

2021-04-27 Thread Amnon
https://blog.cloudflare.com/its-go-time-on-linux/ A bit old, but still relevant. Also https://github.com/dterei/gotsc may be useful depending on your requirements. On Tuesday, 27 April 2021 at 16:54:38 UTC+1 manlio@gmail.com wrote: > Il giorno martedì 27 aprile 2021 alle 17:51:46 UTC+2 Ia

[go-nuts] Re: go build ./... will produce a binary of one and only one main package is found

2021-04-19 Thread Amnon
go build ./... does build you program. I think most people would be a bit surprised if it did something other than build. If you don't want to build your program, but just vet that they are syntactically correct then maybe try something like go vet ./... On Monday, 19 April 2021 at 16:36:14

Re: [go-nuts] gob non-optimal serialization in case of interface

2021-04-04 Thread Amnon
I would agree with Axel, that while gob is convenient, it never claims to be optimal. And if you care about size and speed of encoding then it may be worth looking at other serialisation formats. See https://ugorji.net/blog/benchmarking-serialization-in-go for some alternatives On Sunday,

[go-nuts] Re: Alternate implementations of regular expression matching?

2021-04-02 Thread Amnon
*Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.* I would tend to agree with this statement. Regular expressions are much abused and over-used in situations where simpler parsing techniques would be more appropriate. Beyond

[go-nuts] Re: Alternate implementations of regular expression matching?

2021-04-01 Thread Amnon
Worth mentioning Russ Cox's series of blog posts on Regular Expressions and their implementation https://swtch.com/~rsc/regexp/ On Thursday, 1 April 2021 at 21:21:14 UTC+1 Brian Candler wrote: > If you can live with cgo dependencies, then you might want to look at a go > wrapper around PCRE,

Re: [go-nuts] string matching

2021-04-01 Thread Amnon
Or you could try something like https://play.golang.org/p/xkmchEgyVir On Thursday, 1 April 2021 at 20:02:29 UTC+1 Matt KØDVB wrote: > Use a capture group > > regex := regexp.MustCompile(`.*\bCore Count: (\d+)`) > result := regex.FindAllStringSubmatch(raw, -1) > > https://play.golang.org/p/r_TxhV

[go-nuts] GIL for Go

2021-04-01 Thread Amnon
An exciting announcement from the Go team this morning! The upcoming release of Go 1.17 (due in September) will include GIL for Go, As the Pythonistas among us know, GIL is Python’s Global Interpreter Lock, which has been included in even the earliest versions of Python, but is missing from Go u

Re: [go-nuts] Re: unexpected fault address 0xfffffff800000019

2021-03-25 Thread Amnon
I would check if it reproduces on Go 1.16.2 On Thursday, 25 March 2021 at 05:50:24 UTC Kurtis Rader wrote: > On Wed, Mar 24, 2021 at 8:25 PM Kurtis Rader wrote: > >> On Wed, Mar 24, 2021 at 7:05 PM awer...@gmail.com >> wrote: >> >>> Oh, we've got another confirmed case of the scary runtime er

[go-nuts] Re: what is a minimal setup for compiling go programs in module mode?

2021-03-24 Thread Amnon
You can just tar up your ~/go/pkg/mod directory (plus your own sources) and you will be good. On Wednesday, 24 March 2021 at 16:19:13 UTC jake...@gmail.com wrote: > > I believe I can't use replace? > > I'm glad the vendoring solution is what you want. But IIUC what you are > trying to do, then

Re: [go-nuts] Use cases for custom ResponseWriter

2021-03-17 Thread Amnon
https://github.com/gorilla/handlers contains a number of ResponseWriters to provide functions such as compression and logging On Wednesday, 17 March 2021 at 08:41:09 UTC be...@pferdewetten.de wrote: > net/http/httptest contains an implementation of http.ResponseWriter that's > used for testing

[go-nuts] Re: Is there a final document on generics?

2021-03-17 Thread Amnon
I don't think that a race between competing genetics container collections will necessarily be a bad thing. It will allow flexibility, experimentation, innovation, and it will allow the community to vote with its feet in terms of eventually coalescing around a de-facto standard. On Wednesday, 1

Re: [go-nuts] Contrary to popular opinion...

2021-02-27 Thread Amnon
decisions do make sense to a mere mortal like myself. But one day I will go back to python and try to get my head round some of the intractable paradoxes which have always baffled me. On Saturday, 27 February 2021 at 17:52:41 UTC bobj...@gmail.com wrote: > Thanks, Amnon, for that well known qu

Re: [go-nuts] Contrary to popular opinion...

2021-02-25 Thread Amnon
*There should be one-- and preferably only one --obvious way to do it. * >From the Zen of Python. But also good advice for Gophers. On Friday, 26 February 2021 at 01:03:00 UTC skinne...@gmail.com wrote: > I have a wonderful video of a GO program I wrote over 5 years ago which > will not compile

Re: [go-nuts] Re: Cannot build after upgrading to Go 1.16

2021-02-25 Thread Amnon
Because stdlib was written before modules were a thing. Regarding the "lets keep GOPATH going" argument, there was an issue about this on github where the arguments around the issue were fully explored. https://github.com/golang/go/issues/37755#issuecomment-771879911 > thanks. expressed virt

Re: [go-nuts] Re: Cannot build after upgrading to Go 1.16

2021-02-24 Thread Amnon
Go modules were introduced back in 2018, so we have had a good few years to migrate. In most cases migrating simply means running go mod init, and commiting the go.mod and go.sum files. Migrating does cause a small amount of pain. But it will improve your life as a developer. The existence of

[go-nuts] Code markup in golang-nuts

2021-02-20 Thread Amnon
Slightly off topic. But is there any way to enhance google groups so that it will support Markdown? Or at least provides a simple way to post formatted code without the indentation being destroyed? People often want post code snippets on this group. And I have yet to find an easy way to do this.

Re: [go-nuts] Re: "go1.15 mod tidy" fails if the current project depends on a module containing a file using embed and guarded by "+build go1.16"

2021-02-19 Thread Amnon
go mod tidy has to ignore build tags. Because if it did not ignore build tags, it would delete dependencies needed by other platforms. On Friday, 19 February 2021 at 02:23:45 UTC Ian Lance Taylor wrote: > On Thu, Feb 18, 2021 at 3:29 PM tapi...@gmail.com > wrote: > > > > Thanks for the link.

[go-nuts] Re: The GO equiv. to 'tail -f' ?

2021-02-18 Thread Amnon
What to do depends on the platform. But there are quite a few examples around. https://github.com/hpcloud/tail https://github.com/papertrail/go-tail https://stackoverflow.com/questions/10135738/reading-log-files-as-theyre-updated-in-go etc... On Thursday, 18 February 2021 at 18:50:43 UTC Steve M

Re: [go-nuts] Error handling

2021-02-18 Thread Amnon
OT, but what has happened to the Go 2 error handling proposals? I heard that the original check proposal was abandoned because of the unfortunate interaction with defer. Any updates? On Thursday, 18 February 2021 at 08:30:26 UTC ntr...@gmail.com wrote: > What would be the difference between us

Re: [go-nuts] The Generics Proposal has been accepted!

2021-02-12 Thread Amnon
Thanks, Ian, for the correction, and for all the hard work... All much appreciated! On Friday, 12 February 2021 at 15:49:57 UTC Ian Lance Taylor wrote: > On Fri, Feb 12, 2021 at 7:39 AM Amnon wrote: > > > > And should be out in 1.17 (this Autumn). > > > > Congratula

Re: [go-nuts] The Generics Proposal has been accepted!

2021-02-12 Thread Amnon
at Gophercon 2019 and 2020 https://www.youtube.com/watch?v=WzgLqE-3IhY https://www.youtube.com/watch?v=TborQFPY2IM On Friday, 12 February 2021 at 15:44:42 UTC meera wrote: > Will there be a blog post about this? I really want to know more! > > On Fri, 12 Feb 2021, 12:39 Amnon, wrote:

[go-nuts] The Generics Proposal has been accepted!

2021-02-12 Thread Amnon
And should be out in 1.17 (this Autumn). Congratulations to all those who made it happen, and to the Go team for making sure that the design was right before it was accepted. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from th

[go-nuts] Re: compare of bytes or string?

2021-02-10 Thread Amnon
Matt Godblolt's web app is a fun way to explore these question. https://godbolt.org/z/q6oz64 On Wednesday, 10 February 2021 at 10:12:18 UTC cuiw...@gmail.com wrote: > compare two byte slice,will convert to compare between two string, and my > question is how golang compare two string, i don't th

[go-nuts] Re: Golang can be a foundation project? #44184

2021-02-10 Thread Amnon
This has been discussed extensively in the past. See https://groups.google.com/g/golang-nuts/c/6dKNSN0M_kg/m/PnxOFWP-BgAJ On Tuesday, 9 February 2021 at 23:53:55 UTC hufen...@gmail.com wrote: > https://github.com/golang/go/issues/44184 > > > > 文以载道博学多能 在 2021年2月10日 星期三上午7:53:18 [UTC+8] 的信中寫道: > >

Re: [go-nuts] Possible to make base64 pick the decode encoding automatically?

2021-02-02 Thread Amnon
Reading through a bufio.Reader is often useful for these situations. You can peek the beginning of the input in order to decide which decoder to use. Another option is to use the io.TeeReader to duplicate the reader, and then send one copy to each decoder. One will succeed, and give you the outpu

Re: [go-nuts] How to improve the parallelism of go routine?

2021-02-01 Thread Amnon
Vtune is very useful for squeezing the ultimate performance out of Go programs, once you have done the usual optimisation, mimized allocations, io etc. pprof is more than adequate for the average programmer. But when you need to super-optimise functions which implement math kernels, crypto fun

Re: [go-nuts] Re: Gidelines or best practices on error on error handling?

2021-01-31 Thread Amnon
luted code which is hard to understand, and which is prone to silent breakages. On Sunday, 31 January 2021 at 16:51:12 UTC Jan Mercl wrote: > On Sun, Jan 31, 2021 at 5:24 PM Amnon wrote: > > > https://play.golang.org/p/jnRn4Bv98xS > > > > See the example on the Go Playgro

Re: [go-nuts] Re: Gidelines or best practices on error on error handling?

2021-01-31 Thread Amnon
compile? - amnon On Sunday, 31 January 2021 at 11:19:23 UTC Jan Mercl wrote: > On Sun, Jan 31, 2021 at 8:04 AM Amnon wrote: > > > I really do not like code like > > defer func() { > > if cerr := f.Close(); cerr != nil && err == nil { > > err = cerr > > } &g

[go-nuts] Re: Gidelines or best practices on error on error handling?

2021-01-30 Thread Amnon
ed by f.Close() e.g. if f is a Reader, a bytes.Buffer, or a http.ResponseWriter. - amnon On Saturday, 30 January 2021 at 09:58:56 UTC Uli Kunitz wrote: > You need to think about how important it is for the user of your function > or method to know about the Close error. Usually when

[go-nuts] Re: []byte and string convert?

2021-01-29 Thread Amnon
Generally yes. As strings are immutable, and []byte is not, if you convert from string -> []byte, you need a new copy which can be written without changing the original string (which may be referred to elsewhere). If you convert from []byte -> string, then you need a new copy so that any later

[go-nuts] Re: Virtual time for testing

2021-01-28 Thread Amnon
Try something like github.com/facebookgo/clock On Thursday, 28 January 2021 at 21:15:50 UTC Christian Worm Mortensen wrote: > Hi! > > Suppose I want to unit test this function: > > func generator() <-chan int { > ret := make(chan int) > go func() { > for i := 0; i < 10; i++ { > ret <- i > time.

[go-nuts] Re: super large virtual memory allocation for simplest golang apps, why?

2021-01-14 Thread Amnon
Engineering is about trade-offs. You decide what your priority is, and that largely determines the characteristics of what you produce. The Go core team prioritised maximising throughput on datacentre servers, where cores are plentiful, memory is cheap, and virtual memory is free. And this is r

[go-nuts] Re: super large virtual memory allocation for simplest golang apps, why?

2021-01-13 Thread Amnon
Have you tried https://tinygo.org/ ? On Thursday, 14 January 2021 at 06:02:35 UTC laos...@gmail.com wrote: > a helloworld net/http will ask for 1GB VSS, I understand VSS is not the > same as RSS, also did my googling and know golang malloc.go allocates 512GB > heap for 64bit system and such. >

[go-nuts] Re: [ANN] templatecheck: type-checking Go templates

2021-01-10 Thread Amnon
This is really cool! The world of templates has always been a frightening departure from the type-safety of Go to the wild world of dynamically typed languages, where run-time errors hid in every code path. templatecheck helps eliminate a large class of hard-to-find errors. Thanks for writin

[go-nuts] Re: goproxy.io was deployed in independent region in Europe and America

2021-01-01 Thread Amnon
can't see the graphs. But deployments in additional regions is welcome. On Friday, 1 January 2021 at 17:49:57 UTC not...@gmail.com wrote: > Hi, all > > goproxy.io site was previously deployed in Hong Kong from 2018 with > global CDN, last night the team deployed two independent region in Europe

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

2020-12-30 Thread Amnon
I would like a type-safe version of sync.Map(). On Wednesday, 30 December 2020 at 23:02:48 UTC ren...@ix.netcom.com wrote: > I don't know how Go users can be ‘anti interface’ - literally 95% of the > stdlib is based on interfaces. If you use the stdlib, you use interfaces. > > On Dec 30, 2020,

Re: [go-nuts] json.NewDecoder()/Decode() versus Unmarshal() for single large JSON objects

2020-12-29 Thread Amnon
arge buffer to hold the bytes. Sadly this is not the way encoding/json is implemented. On Tuesday, 29 December 2020 at 16:31:58 UTC axel.wa...@googlemail.com wrote: > On Tue, Dec 29, 2020 at 5:17 PM Amnon wrote: > >> I always use `json.NewDecoder(r.Body).Decode(&payload)` >>

Re: [go-nuts] json.NewDecoder()/Decode() versus Unmarshal() for single large JSON objects

2020-12-29 Thread Amnon
I always use `json.NewDecoder(r.Body).Decode(&payload)` The code is more succinct than reading the entire body into a buffer, and then unmarshalling it. And there is only one error to check. If I was super concerned about people sending trailing gibberish to my server, I could call `dec.Buffere

[go-nuts] Re: json objects

2020-12-28 Thread Amnon
You could try something like this https://play.golang.org/p/a-4i045QdXX On Saturday, 26 December 2020 at 17:49:33 UTC zxj1341...@gmail.com wrote: > In fact, the JSON content you pasted here is NOT valid, cause there > shouldn't be more than one root element in a single JSON file (you can try

Re: [go-nuts] Performance issue with os.File.Write

2020-12-21 Thread Amnon
This is really more of an OS question than a Go language question. Writing single characters is going to be expensive in any language because you pay the considerable overhead of a system call/user-mode to kernel mode context switch overhead for each character. That is why the C stdio library buf

Re: [go-nuts] how to get unsigned url (not signed url)

2020-12-21 Thread Amnon
web sites, whereas a signed URL can also point to negative web sites such as malware, fake news, conspiracy theories etc. Merry Xmas and happy new year to all the gophers here! Wising everyone a much better 2021. - amnon On Monday, 21 December 2020 at 22:59:20 UTC Kurtis Rader wrote: > On

Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-03 Thread &#x27;Amnon Cohen' via golang-nuts
Languages often have a whole variety of loop constructs. C has for loops as well us while loops. Go adopts the principle from the Zen of python: *There should be one-- and preferably only one --obvious way to do it. *It takes a minimalist approach - there is only one looping construct: the for l

Re: [go-nuts] [ANN] CGo-free sqlite database/sql driver 1.4.0 for linux/amd64 released

2020-10-10 Thread Amnon
is something more needed? > > In the first instance you should be theoretically good to go right now on > some popular Linux architectures - namely amd64, 386, arm and arm64. > > Otherwise please let me know about what's missing and I hope it can be > fixed. > > > On S

Re: [go-nuts] [ANN] CGo-free sqlite database/sql driver 1.4.0 for linux/amd64 released

2020-10-10 Thread Amnon
Is there any way we can use this library with Gorm? On Saturday, 29 August 2020 at 00:22:01 UTC+1 xav...@gmail.com wrote: > Thanks Jan, this is very exciting! I'm looking forward to an opportunity > to use this. > > On Wed, Aug 26, 2020 at 2:51 PM Jan Mercl <0xj...@gmail.com> wrote: > >> From th

Re: [go-nuts] Re: Will there be something like "net/quic" in the future?

2020-10-10 Thread Amnon
*Since more and more people is expected to use QUIC in the future, it could be beneficial to include it as part of the Go standard package, as doing so not only could provide a way for server developers to implement QUIC servers/client with ease, but it could also help the net/http implement to

Re: [go-nuts] Re: Will there be something like "net/quic" in the future?

2020-10-08 Thread Amnon
freezing its behaviour. Having it in the standard library would also tie it to Go's six-monthly release cycle, (whereas quic-go seems to get released around once a month). - amnon On Thursday, 8 October 2020 at 17:56:09 UTC+1 axel.wa...@googlemail.com wrote: > I think part of that

[go-nuts] Re: Will there be something like "net/quic" in the future?

2020-10-08 Thread Amnon
Also worth watching the talk by the author https://www.youtube.com/watch?v=BvpRBdWwecU&ab_channel=dotconferences On Thursday, 8 October 2020 at 17:36:12 UTC+1 Amnon wrote: > You can try https://github.com/lucas-clemente/quic-go > > You asked specifically about a builtin package i

[go-nuts] Re: Will there be something like "net/quic" in the future?

2020-10-08 Thread Amnon
You can try https://github.com/lucas-clemente/quic-go You asked specifically about a builtin package i.e. a package in the standard library. But I am not sure what advantages locating new protocols into the standard library would bring. On Thursday, 8 October 2020 at 09:00:20 UTC+1 ran...@gmai

[go-nuts] zero maps rationale

2020-10-07 Thread Amnon
Go generally ensures that zero values are useful. So a zero slice allows us to append to it, without having to do any special initialization. This approach also extends to the standard library. sync.Mutexs are unlocked and usable in the zero state. Even zero sync.Maps ready for use. So why ar

[go-nuts] Go is easy to lean. But other languages are hard to forget

2020-10-04 Thread Amnon
Go is a beautifully simple language. It is easy to learn. Most programmers can learn to write working production code within a day. But learning Go is the easy thing. It is much much harder to liberate yourself from the conceptual baggage that you have inherited from languages in your past. Ever

[go-nuts] Re: Proposal: auto return String instead of []byte if requested

2020-09-11 Thread Amnon
People tend to use strings far too much. Does tlsCert in this code really need to be a string? Probably not. But it it does really need to be a string, then converting to a sting as you have done is quite straight forward. And explicit is better than implicit. The beauty of Go is its simplicity

Re: [go-nuts] cgo cross compilation to arm failed

2020-09-08 Thread Amnon
Cross compilation of CGO stuff requires a lot of faff. I spend several years doing embedded development, and messing about with GCC build-chains. So I was absolutely astounded that the Go build tools do everything with two env vars. Once you branch out to CGO, you are back in the hairy world of

[go-nuts] Re: regexp group multi Replace Pattern

2020-09-02 Thread Amnon
There are various projects that combine multiple regexps into a single DFA. Have a look at https://github.com/proebsting/re On Wednesday, 2 September 2020 21:23:40 UTC+1, Brian Candler wrote: > > Can you define the problem more clearly? > > It looks like you just want to replace a leading "9", "00

[go-nuts] Re: Using go build to cross compile a kernel file and link it to the loader

2020-08-29 Thread Amnon
Go is not the best language to write a kernel on. But some people have done it as an intellectual exercise. Look at https://github.com/ycoroneos/G.E.R.T Or https://github.com/f-secure-foundry/tamago Or read https://speakerdeck.com/achilleasa/bare-metal-gophers-can-you-write-an-os-kernel-in-go It

[go-nuts] Re: Not able to validate response body - new to golang - mock unexpected method call

2020-08-28 Thread Amnon
Welcome to the world of Go. The formatting of your snipped does not seem quite right to me, which makes it hard for me to read. I would try to put a minimal runnable example which reproduces the problem in https://play.golang.org/ and posting it here. Best, Amnon On Friday, 28 August 2020 18

Re: [go-nuts] [ANN] CGo-free sqlite database/sql driver 1.4.0 for linux/amd64 released

2020-08-27 Thread Amnon
Fantastic work! And this will be super useful to the community. I have used sqlite memory dbs for unit tests in the past, and this always caused me portability pain. Just one question. How will you track upstream changes in the original C sqlite? On Thursday, 27 August 2020 14:24:23 UTC+1, Jan

Re: [go-nuts] New linker

2020-08-18 Thread Amnon
Ian, Than - thanks for the info and the hard work. Looking forward to putting the new linker through its paces! On Tuesday, 18 August 2020 20:35:54 UTC+1, Ian Lance Taylor wrote: > > On Sat, Aug 15, 2020 at 11:49 PM Amnon > > wrote: > > > > Austin's doc refers

Re: [go-nuts] New linker

2020-08-16 Thread Amnon
As an aside, for those who do not know, Ian wrote the Gold linker, which sped up linking by a factor of 100. https://lwn.net/Articles/276782/ provides an index to his 20 part blog post on linkers. On Sunday, 16 August 2020 07:49:16 UTC+1, Amnon wrote: > > Thanks for the answer! > >

Re: [go-nuts] New linker

2020-08-15 Thread Amnon
gly little information about it. It is almost invisible - which I suppose is a tribute to its success. But are there any talks about the new linker which are worth watching? - Amnon On Sunday, 16 August 2020 05:46:53 UTC+1, Ian Lance Taylor wrote: > > On Sat, Aug 15, 2020 at 11:49 AM

[go-nuts] New linker

2020-08-15 Thread Amnon
What is the best place to read about the ongoing work on the new linker? With the Go 1.15 release, how far along are we with the plans? What has been achieved? And what is still to come? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscr

Re: [go-nuts] JSON stream parsing help

2020-07-25 Thread Amnon BC
Awesome, thanks! On Sat, Jul 25, 2020 at 3:50 PM burak serdar wrote: > On Sat, Jul 25, 2020 at 6:09 AM Amnon wrote: > > > > Hi, > > > > I need to consume a stream of json objects. > > But unfortunately the json objects are separated by commas. > > > &g

[go-nuts] JSON stream parsing help

2020-07-25 Thread Amnon
.EOF { break } if err != nil { log.Fatalln(err) } log.Println(a) } https://play.golang.org/p/7lBhs0pXUx8 Unfortunately the json comes from an external service, so I can't stop it inserting unecessesary comments. Thanks for any ideas, Amnon -- You received this message because you are s

[go-nuts] Re: Go 1.15 Release Candidate 1 is released

2020-07-25 Thread Amnon
Cool. go1.15rc1 gives a 8% speedup on my tests. On Friday, 24 July 2020 20:21:50 UTC+1, Alexander Rakoczy wrote: > > Hello gophers, > > We have just released go1.15rc1, a release candidate version of Go 1.15. > It is cut from release-branch.go1.15 at the revision tagged go1.15rc1. > > Please tr

[go-nuts] Re: Allocating lots (e.g. a million) objects on the heap

2020-07-21 Thread Amnon
Try a naive solution, and see if it is good enough, before optimising. On Monday, 20 July 2020 18:35:14 UTC+1, netconn...@gmail.com wrote: > > I have an application where I will be allocating millions of data > structures, all of the same size. My program will need to run continuously > and be

[go-nuts] Re: module questions

2020-07-21 Thread Amnon
GOPRIVATE is your friend. https://golang.org/cmd/go/#hdr-Module_configuration_for_non_public_modules On Monday, 20 July 2020 20:40:19 UTC+1, K Richard Pixley wrote: > > I'm think I understand the go-1.14 downloadable module workflow. But I'm > not getting how to use modules in an enterprise syst

Re: [go-nuts] draft design for // +build replacement

2020-07-06 Thread Amnon
A sensible, well thought out, design. My main worry is that we will come unstack in places that are using versions of the Go toolchain older than N-2. Is there any reason for them not to upgrade? No Should they upgrade? Definitely But some still haven't. Perhaps we should force them to upgrade t

[go-nuts] Re: clean unused packages in $GOPATH/pkg/mod

2020-07-06 Thread Amnon
Just delete them all. Your next build will repopulate the ones that are needed. -- 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...@googlegrou

[go-nuts] Re: defer func() { _ = resp.Body.Close() }()

2020-06-27 Thread Amnon
Feel free to use it. - amnon On Wednesday, 16 August 2017 13:05:39 UTC+1, Gert wrote: > > To pass errcheck I need to do something like > > defer func() { _ = resp.Body.Close() }() > > instead of > > defer resp.Body.Close() > > Is this something the errcheck t

[go-nuts] Re: political fundraising on golang.org!

2020-06-15 Thread Amnon
The Go community includes programmers of all races, nationalities and cultures. Every member of the community has the right to go about their daily lives without being killed by the police force. I applaud the decisions of the Go team to take a public stand in favour of this right. I am surpri

[go-nuts] Re: political fundraising on golang.org!

2020-06-14 Thread Amnon Baron Cohen
I, for one, applaud the posting of the banner. Solidarity! On Sunday, 14 June 2020 14:36:38 UTC+1, peterGo wrote: > > Recently, a political message with a fundraising link appeared as a banner > atop golang.org websites: https://golang.org/, https://pkg.go.dev/. > > content/static: add Black Liv

[go-nuts] Re: what is the complexity of regexp.MustCompile()?

2020-06-08 Thread Amnon Baron Cohen
Should we care? Regular expressions are generally small. So the asymptotic complexity is not particularly important. But regular expressions are often used to search large amounts of input. regexp gives us fast, guaranteed linear search times. But we pay for this with slower compilation times.

[go-nuts] Re: Need help with go modules

2020-05-23 Thread Amnon Baron Cohen
I would work through https://golang.org/doc/code.html - Amnon On Friday, 22 May 2020 12:59:03 UTC+1, lj0...@gmail.com wrote: > > It looks like I am not only one to struggle with (new?) go modules. > I still consider me as novice to GO but the major problem is as usual, the > f

[go-nuts] Re: How to work with multiple environment like dev, test, staging, prod in golang ?

2020-05-17 Thread Amnon Baron Cohen
My advice is to use the same application-dev.yml, application-test.yml, application-prod.yml YAML files that you are familiar with, and have your application read its config from them. Changing language does not mean that you have to change the way you configure your application. On Sunday,

[go-nuts] Re: Type Assertion on File type

2020-05-07 Thread Amnon Baron Cohen
The beautiful thing about Go is that it is statically typed, so you don't need to check if your function returned an *os.File. The compiler already did it for you On Thursday, 7 May 2020 17:57:05 UTC+1, André kouamé wrote: > > Hi, > > I want to check, if the value return by my function has th

[go-nuts] Re: DisableKeepAlive not being honored in http.transport

2020-05-07 Thread Amnon Baron Cohen
information. Hope this helps... - Amnon On Thursday, 7 May 2020 15:13:04 UTC+1, Ryan Rank wrote: > > This is what I did, and see no change in behavior. > > for i := 0; i < 10; i++ { > response, err :=client.Get("https://foo.com";) > if

[go-nuts] Re: DisableKeepAlive not being honored in http.transport

2020-05-06 Thread Amnon Baron Cohen
} Hope this helps - Amnon On Wednesday, 6 May 2020 19:01:55 UTC+1, Ryan Rank wrote: > > I wrote a small program that runs a repeated GET against a given URL. > However, the DisableKeepAlives boolean does not seem to be honored. Code is > similar to this: > &g

[go-nuts] Re: Need help with go modules

2020-05-05 Thread Amnon Baron Cohen
ch as github and use the vcs path as an argument to go mod init e.g. go mod init github.com/myuser/myrepo - Amnon On Monday, 4 May 2020 14:59:22 UTC+1, web user wrote: > > I have a personal project using GOPATH > > But recently, I wanted to use go-redis for a project and v7 forces you to

Re: [go-nuts] json decode is very slow

2020-05-03 Thread Amnon Baron Cohen
; or something in front of it. Since you have a fast and a slow system, you > can slot each in and look for differences in how the system is operating. > > On Thu, Apr 30, 2020 at 1:14 PM Sarath Prabath Redlapalli Jaya < > harrysa...@gmail.com > wrote: > >> Than

[go-nuts] Re: json decode is very slow

2020-05-01 Thread Amnon Baron Cohen
That was my fault too. encoding/json is slow, but not that slow. Unfortunately the title of this thread is a bit misleading. Apparently what is taking time here is reading the data off the wire, rather than decoding the data once it has arrived. So it seems that that the slowness is probably not

[go-nuts] Re: json decode is very slow

2020-04-30 Thread Amnon Baron Cohen
encoding/json is quite old and not particularly fast. There are some other implementations around which use code generation rather than reflection, and which claim to give a speedup of 3x or meore I would try one of them: https://github.com/mailru/easyjson or https://github.com/pquerna/ffjson On

[go-nuts] Re: the size of the files compiled in GO

2020-04-19 Thread Amnon Baron Cohen
Executable size for small programs is not a top priority in gc. So if you care about executable size (e.g. if your code runs on microcontrollers, or WASM), you may want to have a look at https://tinygo.org/ . On Sunday, 19 April 2020 21:18:29 UTC+1, serhat...@gmail.com wrote: > > It is one of the

[go-nuts] Re: [ANN] Go Brain Teasers (book)

2020-04-18 Thread Amnon Baron Cohen
give us a few samples to whet our appetite! On Saturday, 18 April 2020 10:15:57 UTC+1, Miki Tebeka wrote: > > Hi, > > I'm happy to announce that my book is finally out. It contains 25 brain > teasers to tickle your mind. > - Gumroad (ePub & PDF) https://gum.co/Qkmou > - Amazon (mobi & dead tree)

[go-nuts] Re: "Timers rely on the network poller", why is that?

2020-04-17 Thread Amnon Baron Cohen
The go runtime does its waiting (both for timers and network events) in netpoll. On Friday, 17 April 2020 11:10:58 UTC+1, Vincent Blanchon wrote: > > Hi everyone, > > From what I understand, timers are ran by: > - the P holding them > - other P if timer-stealing happen (thanks to the async preemp

Re: [go-nuts] testing code that uses ioutil.ReadDir?

2020-04-13 Thread Amnon Baron Cohen
"Coverage is a proxy for testing quality, but not a guarantee of it. Getting to 100% coverage is a better indicator of chasing metrics than of actually writing good tests" Wise words indeed. I'm going to print out this quote and frame it. Thanks Rob! On Monday, 13 April 2020 17:07:25 UTC+1, K

[go-nuts] Re: Intercepting field access and method call

2020-04-12 Thread Amnon Baron Cohen
Go is a simple language. Code in Go does what it says. No magic. That is its beauty. That is its power. On Sunday, 12 April 2020 03:59:08 UTC+1, Tanmay Das wrote: > > Say you have a struct Foo and you access fields and call methods on it as > you normally would. But is it possible to execute

Re: [go-nuts] Go course

2020-03-29 Thread Amnon Baron Cohen
Thanks! A great write-up. On Friday, 27 March 2020 16:32:51 UTC, Owen Waller wrote: > > Hi Dave, > > As the original author of the post that Dan has referenced, I can say that > Go does indeed make IMHO a good first programming language. It all comes > down to how you explain things. Thanks Dan

Re: [go-nuts] Go course

2020-03-26 Thread Amnon Baron Cohen
The println and print builtin may be removed from the language in the future. On Thursday, 26 March 2020 19:18:50 UTC, David Riley wrote: > > And since I'm a fan of lifelong learning, I have to admit to not having > known that println() was a builtin until this post. Thanks! That does > un-comp

Re: [go-nuts] Go course

2020-03-26 Thread Amnon Baron Cohen
Go is not C. C programmers have to master explicit memory management, which is a challenge to new and experience programmers alike. C is a beautiful language. But very low level. Having spent several years programming in Python, I would say that it is much more complicated than Go. It has a larg

[go-nuts] Re: json to golang struct definition lib

2020-03-26 Thread Amnon Baron Cohen
An interesting approach. Slightly surprised you did not use "encodeing/json" to parse the json input, which would have been much easier. On Thursday, 26 March 2020 00:05:01 UTC, sanye wrote: > > Hello gophers, > > I found an interesting project: https://github.com/mholt/json-to-go , > which tra

[go-nuts] Re: I'm writing my website in golang but there is issue called 404 page not found

2020-03-09 Thread Amnon Baron Cohen
Also worth adding some unit tests, including one which reproduces your 404 error. See https://www.youtube.com/watch?v=hVFEV-ieeew for a great video about how to add these tests. On Monday, 9 March 2020 14:53:20 UTC, anderso...@blacklane.com wrote: > > please post the code as text. Either in a

[go-nuts] Re: Changing source code in order code to be supported from older Golang versions e.g. Go 1.10

2020-03-08 Thread Amnon Baron Cohen
; > On Friday, March 6, 2020 at 1:20:38 PM UTC-5, Amnon Baron Cohen wrote: >> >> Anyone who is able to put up with a 20 year old OS >> will be able to tolerate a 2 year old Go version... >> > > Dimitrios' question is a perfectly legitimate one. Your response doe

Re: [go-nuts] Changing source code in order code to be supported from older Golang versions e.g. Go 1.10

2020-03-07 Thread Amnon Baron Cohen
also https://stackoverflow.com/questions/52137098/go-after-1-10-and-support-of-windows-xp/52137703#52137703 On Saturday, 7 March 2020 13:38:17 UTC, Amnon Baron Cohen wrote: > > https://github.com/golang/go/issues/23380 > > > -- You received this message because you are subscribe

Re: [go-nuts] Changing source code in order code to be supported from older Golang versions e.g. Go 1.10

2020-03-07 Thread Amnon Baron Cohen
https://github.com/golang/go/issues/23380 On Saturday, 7 March 2020 11:42:28 UTC, Jesper Louis Andersen wrote: > > While it isn't supported, it might be there are not that much work needed > to make 1.14 run on Windows XP. At least you should consider that path as > well in addition to program r

<    1   2   3   >