Re: [go-nuts] nil map assignment panics. can we do better?

2019-09-23 Thread abuchanan via golang-nuts
Ah, thanks Ian, that's exactly the kind of requirement I was looking for. (also, you said "without" but you probably meant "while") Perhaps this is a job for "go vet". And/or, looks like staticcheck.io has a check I can try: https://staticcheck.io/docs/checks#SA5000 On Monday, September

[go-nuts] Re: VsCode syntax highlighting for tmpl files

2019-09-23 Thread Subramanian Sridharan
Nunjucks seems to do the trick. Nunjucks - Visual Studio Marketplace ext install extension nunjucks > When you save a file with some file extension, VSCode automatically prompts you to install a related VSCode extension.

Re: [go-nuts] using Go as a configuration file format

2019-09-23 Thread Kurtis Rader
On Mon, Sep 23, 2019 at 9:38 PM Dan Kortschak wrote: > Have you ever considered using Go as the configuration format for your > project? Have you wondered whether you need a Turing complete > configuration language? > > Of course not; here it is: https://github.com/kortschak/yaegiconf > >

Re: [go-nuts] Unable to post on this subject

2019-09-23 Thread Ian Lance Taylor
On Mon, Sep 23, 2019 at 8:26 AM wrote: > > > Trying to post on the golang-nuts subject but I get: > > > > ‘An Error occurred while communicating with the server’ RELOAD > > > > I have tried different laptops with Windows and Linux OS. > > > > Don’t know if it’s me of the thread as there is no

Re: [go-nuts] nil map assignment panics. can we do better?

2019-09-23 Thread Ian Lance Taylor
On Mon, Sep 23, 2019 at 2:40 PM abuchanan via golang-nuts wrote: > > Is there anything written down on why assignment to a nil map causes a panic? > I'm curious if there were carefully considered tradeoffs while making this > decision. > > Assignment to nil maps has caused most of the

[go-nuts] using Go as a configuration file format

2019-09-23 Thread Dan Kortschak
Have you ever considered using Go as the configuration format for your project? Have you wondered whether you need a Turing complete configuration language? Of course not; here it is: https://github.com/kortschak/yaegiconf Appalled? OK. -- You received this message because you are subscribed

Re: [go-nuts] HTTP:ListenAndServe questions

2019-09-23 Thread joe mcguckin
Thanks! That clears up a couple of nagging questions I had. Joe On Monday, September 23, 2019 at 7:45:16 PM UTC-7, Ben Burwell wrote: > > On Mon Sep 23, 2019 at 5:50 PM joe mcguckin wrote: > > In ListenAndServe, I see that it calls (*Server).Serve(ln), then 'go > c.serve(ctx)' > > I can't

Re: [go-nuts] HTTP:ListenAndServe questions

2019-09-23 Thread Ben Burwell
On Mon Sep 23, 2019 at 5:50 PM joe mcguckin wrote: > In ListenAndServe, I see that it calls (*Server).Serve(ln), then 'go > c.serve(ctx)' > I can't find a function named 'serve'. Where is this? On line 1760 of the same file, server.go. > Does HTTP manage a pool of coroutines or does it create

Re: [go-nuts] package_test can't find local package

2019-09-23 Thread Dan Kortschak
Resolved. Module name must be fully qualified. On Tue, 2019-09-24 at 11:19 +0930, Dan Kortschak wrote: > I'm putting together a tiny package at the moment that has not yet > been > push to a git remote. When I try to run tests I get the following > failure: > > $ GOPROXY=off go test > #

[go-nuts] package_test can't find local package

2019-09-23 Thread Dan Kortschak
I'm putting together a tiny package at the moment that has not yet been push to a git remote. When I try to run tests I get the following failure: $ GOPROXY=off go test # yaegiconf package yaegiconf_test imports github.com/kortschak/yaegiconf: cannot find module providing package

[go-nuts] HTTP:ListenAndServe questions

2019-09-23 Thread joe mcguckin
In ListenAndServe, I see that it calls (*Server).Serve(ln), then 'go c.serve(ctx)' I can't find a function named 'serve'. Where is this? Does HTTP manage a pool of coroutines or does it create one for every incoming HTTP request. It's clear where the first request gets handled but where do

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread 'Keith Randall' via golang-nuts
In the runtime we use structs like these, but with unsafe.Pointer data fields (runtime.stringStruct and runtime.slice). They are much safer to use than reflect's types with uintptr Data fields. Unfortunately we can't change reflect's types because of the Go 1 compatibility guarantee. You can

Re: [go-nuts] Need a Modules for Dummy's Guide. Please help

2019-09-23 Thread Marcin Romaszewicz
I've beat my head into the module wall a bit as well, and while I don't understand some of the design decisions, I've done my best to answer your questions inline. On Mon, Sep 23, 2019 at 1:42 PM Stuart Davies wrote: > Hi. > > > > I have been using GO for about a year and I love the language

[go-nuts] Re: go 1.13 won't compile

2019-09-23 Thread Robert Solomon
If I understand you, you want me to not use ~/go/sec? That confuses me. Am I getting expected behavior? -- 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

[go-nuts] Re: Unable to post on this subject

2019-09-23 Thread Stuart Davies
It's ok now. Got my post done. Thanks. On Monday, 23 September 2019 16:26:15 UTC+1, stuart...@bt.com wrote: > > Hi > > > > Trying to post on the golang-nuts subject but I get: > > > > ‘An Error occurred while communicating with the server’ RELOAD > > > > I have tried different laptops

[go-nuts] nil map assignment panics. can we do better?

2019-09-23 Thread abuchanan via golang-nuts
Is there anything written down on why assignment to a nil map causes a panic? I'm curious if there were carefully considered tradeoffs while making this decision. Assignment to nil maps has caused most of the unexpected panics I've seen. Many times these happen in production and cause an

[go-nuts] Re: Unable to post on this subject

2019-09-23 Thread cinematown
well, google is awesome but is not perfect :) On Monday, September 23, 2019 at 6:26:15 PM UTC+3, stuart...@bt.com wrote: > > Hi > > > > Trying to post on the golang-nuts subject but I get: > > > > ‘An Error occurred while communicating with the server’ RELOAD > > > > I have tried different

[go-nuts] Need a Modules for Dummy's Guide. Please help

2019-09-23 Thread Stuart Davies
Hi. I have been using GO for about a year and I love the language and ideas behind the language. I am also a Java developer for many years, I switched from Delphi to Java 1, the new and exciting language from Sun (a bit like GO is now from Google). In Java we have Maven and Gradle

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread Robert Engels
As someone that has worked with a lot of similar libraries in the HFT space - things like UnsafeString or FastString in Java I would caution against doing this in Go - especially as proposed here. Taking an immutable object like string and making it mutable by accident is a recipe for disaster.

Re: [go-nuts] Dependency injection in gorillamux handlers

2019-09-23 Thread 'Abhinav Gupta' via golang-nuts
You can place the dependencies into a struct and use a bound method on that as your handler. So you build a struct that will hold application-scoped objects like Redis client, content.Updater, etc. package contact type Handler struct { Redis *redis.Client Updater *content.Updater

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

[go-nuts] Unable to post on this subject

2019-09-23 Thread stuart.d.davies
Hi Trying to post on the golang-nuts subject but I get: 'An Error occurred while communicating with the server' RELOAD I have tried different laptops with Windows and Linux OS. Don't know if it's me of the thread as there is no error details or reason. Any Ideas? Regards Stuart Davies (BT

[go-nuts] VsCode syntax highlighting for tmpl files

2019-09-23 Thread cinematown
Is there way to highlight templates files (.tmpl) in VSCode? There is an extension gotemplate-syntax but seems it doesn't make the job. {{define "side"}} New Books There's nothing here {{end}} -- You

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

2019-09-23 Thread sdd . davies
Hi. I have been using GO for about a year and I love the language and ideas behind the language. I am also a Java developer for many years, I switched from Delphi to Java 1, the new and exciting language from Sun (a bit like GO is now from Google). In Java we have Maven and Gradle

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread Francis
So I think the current state of unsafe conversions of string <-> []byte is roughly 1. Use the reflect Slice/StringHeader struct. These structs give you clear fields to set and read from. If the runtime representation of a string or []byte ever changes then these structs should change to

[go-nuts] Any support for proxy certificates (RFC3820) ?

2019-09-23 Thread Christophe Meessen
Hello, I need to write go code dealing with proxy certificates (RFC3820). They are sometimes referred to as Grid Security Infrastructure (GSI) certificates I couldn’t find anything related in crypto or x/crypto. Any suggestion ? -- You received this message because you are subscribed to the

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread Dan Kortschak
Any particular reason for that? Neither is safer than the other and it's not clear to me that you can actually achieve the goal of having a compile-time check for the correctness of this type of conversion. On Mon, 2019-09-23 at 02:36 -0700, fran...@adeven.com wrote: > But this relies on a

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread francis
That's super interesting. Thanks for the pointer Jan :bow: On Monday, September 23, 2019 at 11:42:55 AM UTC+2, Jan Mercl wrote: > > On Mon, Sep 23, 2019 at 11:37 AM > wrote: > > > ... and the problems with storing a uinptr in a variable are mostly > related to moving garbage collectors ... > >

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread Jan Mercl
On Mon, Sep 23, 2019 at 11:37 AM wrote: > ... and the problems with storing a uinptr in a variable are mostly related > to moving garbage collectors ... Please note that even though, AFAIK, none of the Go compilers so far uses a moving GC, it's not the only source of objects being moved

Re: [go-nuts] Dependency injection in gorillamux handlers

2019-09-23 Thread Nathanael Curin
I'm avoiding context.WithValue since I feel the objects I'm dealing with are too "powerful" (i.e. not simple Values). For a read, a 2016 article on this : https://peter.bourgon.org/blog/2016/07/11/context.html I remember reading through another article saying the usage of WithValue is kind of

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread francis
That would work Kortschak. But this relies on a string's representation being the same as, but a bit smaller thabn, a []byte. I would prefer to use the Slice/StringHeader. It's worth noting that _most_ of the problems I described in my initial post are hypothetical at this stage. The issue

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread francis
That would work Kortschak. But this relies on a string's representation being the same as, but a bit smaller thabn, a []byte. I would prefer to use the Slice/StringHeader. It's worth noting that _most_ of the problems I described in my initial post are hypothetical at this stage. The issue

Re: [go-nuts] Dependency injection in gorillamux handlers

2019-09-23 Thread Andrew Pillar
Why don't you use context.WithValue(r.Context(), , ) for passing the injected values you want to your HTTP handlers. Then defer the logic for retrieving whatever you want for that handler to a middleware function. -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: go 1.13 won't compile

2019-09-23 Thread Dmitry Savintsev
> I do not have, need or use a go.mod. I would still recommend to give it a try - it will likely make your Go dev life easier :) Try to follow this recipe - you probably don't need to understand much of what's going on "up front" to get your code to build/test: * assuming your Github /

[go-nuts] Dependency injection in gorillamux handlers

2019-09-23 Thread Nathanael Curin
Hi everyone, I'm currently using the gorilla/mux package to make an API with a few handlers that depend on multiple external resources (a Redis DB for example). The fact is, HTTP Handlers only use http.ResponseWriter and *http.Request as parameter, so I used some random dependency injection