Re: [go-nuts] Differentiating between reader and writer errors

2018-02-07 Thread Jakob Borg
On 7 Feb 2018, at 14:45, Justin Azoff mailto:justin.az...@gmail.com>> wrote: Is there some way to inspect that error to figure out that it was related to reading from 'gr' and not writing to /dev/null? Two options that come to mind are - handling the copy yourself so you get separate Read() a

Re: [go-nuts] ioutil.ReadAll()

2018-02-14 Thread Jakob Borg
On 14 Feb 2018, at 10:50, mrx mailto:patrik@gmail.com>> wrote: resp, err := http.Get("http://example.com/";) if err != nil { // handle error } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) That err returned from ReadAll. I cannot see how that can possibly fail. Yo

Re: [go-nuts] Client certificate in request missing

2018-02-19 Thread Jakob Borg
Try without using Config.BuildNameToCertificate. That’s a server side thing and I doubt it does what you want on the client side. //jb On 16 Feb 2018, at 14:41, mzou...@gmail.com wrote: Hello this is my code: https://play.golang.org/p/yxhYXEVMPjB I got certificate i

Re: [go-nuts] simple sprintF output question

2018-02-21 Thread Jakob Borg
You’re quoting the help for %x for strings and byte slices. For integers it simply says "base 16, with lower-case letters for a-f” and thus behaves like any other number base usually does. In this case, you want “%02x”. //jb On 21 Feb 2018, at 12:06, David Renne mailto:davidre...@gmail.com>> w

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-26 Thread Jakob Borg
On 26 Feb 2018, at 16:38, d...@veryhaha.com wrote: Will the "sync/atomic" package get broken? This atomic package imports unsafe. If changes to unsafe break sync/atomic it’s up to the Go team to fix sync/atomic before releasing. Much like it’s up to other package author

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-26 Thread Jakob Borg
On 26 Feb 2018, at 18:21, "d...@veryhaha.com<mailto:d...@veryhaha.com>" mailto:d...@veryhaha.com>> wrote: On Monday, February 26, 2018 at 11:48:36 AM UTC-5, Jakob Borg wrote: On 26 Feb 2018, at 16:38, di...@veryhaha.com wrote: Will the "sync/atomic" package

Re: [go-nuts] best practices of client middleware

2018-03-07 Thread Jakob Borg
On 7 Mar 2018, at 08:07, Eyal Posener wrote: > > Very Nice stuff - shame he didn't merge it. > But I see that you changes the request in the RoundTrip function, which is > claimed as forbidden in the docs. > Again, I don't understand why the docs forbid it… I expect that this is so that the use

Re: [go-nuts] best practices of client middleware

2018-03-07 Thread Jakob Borg
I haven’t written anything like that, I’m merely offering a suggestion on why the docs say not to do it. On 7 Mar 2018, at 09:28, eyal mailto:pose...@gmail.com>> wrote: In your tests in the round-trippers you do change the requests, as far as i can see. On Wed, Mar 7, 2018 at 10:13 AM

Re: [go-nuts] The result of yaml.Unmarshal() is different between osX and linux

2018-03-16 Thread Jakob Borg
You’re getting an error on the file read. Print the error to see what it is, instead of a hardcoded string. On 16 Mar 2018, at 08:24, dev.ys084...@gmail.com wrote: Recently I started to use golang in project and I got one problem. The problem is the result of yam

Re: [go-nuts] http: unexpected EOF reading trailer not a temporary error?

2018-04-17 Thread Jakob Borg
I think the definition of "temporary" is the issue here. Something like an underlying EAGAN is "temporary" - retrying the same operation that failed on the same socket again can succeed. A read error from a closed TCP connection is not temporary - reading again cannot possibly unclose the connec

Re: [go-nuts] math/big oddities

2018-04-18 Thread Jakob Borg
That is a much too large value to be precisely represented by a float64. You need more bits, and you need to tell big.Float how many bits that is: https://play.golang.org/p/btm6-_9NQgB //jb On 18 Apr 2018, at 09:57, agruet...@gmail.com wrote: I have been playing wit

Re: [go-nuts] Html is not parsing while parsing a template to send email

2018-05-04 Thread Jakob Borg
Hi, Your post is a bit confusing and I think you may be using the word "parse" in the opposite of it its common meaning. However, if you want to pass a HTML fragment through a HTML template and have it not be escaped, look at the template.HTML type: https://golang.org/pkg/html/template/#HTML /

Re: [go-nuts] Html is not parsing while parsing a template to send email

2018-05-04 Thread Jakob Borg
Like this; https://play.golang.org/p/VVIOY7s9xQq //jb On 4 May 2018, at 13:32, Amandeep Kaur mailto:amandeepkaur4...@gmail.com>> wrote: Hi, Jakob Borg Thanks for ypur reply to the post. The solution you have provided can not be implemented on my system. I have provided a small sample

Re: [go-nuts] How to know if interface{} data is nil w/o reflecting?

2018-05-08 Thread Jakob Borg
On 8 May 2018, at 15:26, scude...@gmail.com wrote: But this crashes when foo is really a nil pointer to a type which does support Stringer. The crash isn’t on “your” side though, it’s presumably inside the String() method. Hence, the caller passed you something invalid

Re: [go-nuts] How to know if interface{} data is nil w/o reflecting?

2018-05-08 Thread Jakob Borg
> On 8 May 2018, at 16:19, Michael Cohen wrote: > > Well no - the error I get is that I am attempting to call String() method on > a null receiver - so the caller just passed me a regular nil object. They passed you a totally legit fmt.Stringer which then panicked when you called String() on

Re: [go-nuts] time.Time round/truncate not removing nanosceonds component

2018-05-14 Thread Jakob Borg
Truncate(0) is not supposed to remove the nanoseconds part; it removes the monotonic time part. It just happens that the nanoseconds are zero on the "clock" on play: https://play.golang.org/p/Kdq_SDTi664 To remove the subsecond part use .Truncate(time.Second) (or the corresponding Round of cou

Re: [go-nuts] Load balancing with error feedback capabilities

2018-05-18 Thread Jakob Borg
That also means anyone else can call Lock() and Unlock() on your type. This is often not what you want, unless your type *is* a kind of lock (as opposed to *uses* a lock). On 18 May 2018, at 23:45, matthewju...@gmail.com wrote: By embedding I meant this: type Se

Re: [go-nuts] cgo and time.After

2018-05-19 Thread Jakob Borg
On 19 May 2018, at 16:25, Chris Burkert wrote: > > case <-time.After(5 * time.Second): > fmt.Printf("Progress: %d left from %d\n", remaining, amount) It's not super clear from your post if you're aware of this already, but this case will only fire after the select has been blocked f

Re: [go-nuts] time.Now takes ~3758 ns/op, is that normal?

2018-05-24 Thread Jakob Borg
Are you using the latest version of Go? time.Now() has been optimized recently. On 24 May 2018, at 10:08, ran...@gmail.com wrote: I been working on something performance intensive lately, one feature of it require me to calculate the time gap between operation which requ

Re: [go-nuts] time.Now takes ~3758 ns/op, is that normal?

2018-05-24 Thread Jakob Borg
0 and devel +65c365bf0f Wed May 23 23:51:30 2018 + linux/amd64, the result is the same (slow). On Thursday, May 24, 2018 at 4:37:47 PM UTC+8, Jakob Borg wrote: Are you using the latest version of Go? time.Now() has been optimized recently. On 24 May 2018, at 10:08, ra...@gmail.com wrote: I been

Re: [go-nuts] How to update packages without duplicating distro packages

2018-08-08 Thread Jakob Borg
What’s happening here is that you are pulling in more dependencies than you expect. $ rm -rf ~/go $ go get -u mvdan.cc/sh/cmd/shfmt In those commands, you downloaded the repo mvdan.cc/sh and build cmd/shfmt that is part of it, while also downloa

Re: [go-nuts] How to update packages without duplicating distro packages

2018-08-08 Thread Jakob Borg
On 9 Aug 2018, at 00:09, Kevin Locke mailto:ke...@kevinlocke.name>> wrote: Thanks for the explanation! Is there a way for me to update the locally installed packages (shfmt and its dependencies in this example) without installing additional dependencies which weren't initially installed? You ne

Re: [go-nuts] How to update packages without duplicating distro packages

2018-08-09 Thread Jakob Borg
On 9 Aug 2018, at 18:13, Kevin Locke wrote: > > That is great! `gobin -u` is very close to what I was looking for. > I think it will be sufficient for my needs. Thank you! > > I'm surprised this isn't part of the go tool, since it seems like all > system administrators would need to use gobin

Re: [go-nuts] Re: Cross-compiled program for Raspberry Pi crashes

2018-08-13 Thread Jakob Borg
It’s a bug in the library if it uses 64 bit atomic operations without ensuring 64 bit alignment. Putting the alignment-required field at the top of the struct is the traditional method. //jb On 14 Aug 2018, at 08:45, Stephan Mühlstrasser mailto:stephan.muehlstras...@gmail.com>> wrote: Am Mont

Re: [go-nuts] Problems with cache

2018-08-25 Thread Jakob Borg
On 25 Aug 2018, at 15:21, Peter Kleiweg mailto:pklei...@xs4all.nl>> wrote: disabling the cache won't be an option in Go 1.12. What to do then? You don’t say what your issues with the build cache are. If you did, you might get suggestions. //jb -- You received this message because you are sub

Re: [go-nuts] Is it possible to build a module without a hosted repository?

2018-09-14 Thread Jakob Borg
I’m not sure I understand. My "go build" doesn’t reach out anywhere to build a local program: $ mkdir /tmp/project && cd /tmp/project/ $ cat > main.go package main import "fmt" func main() { fmt.Println("Oi") } $ cat > go.mod module totally/fake/project $ go build $ ./project Oi On 15 Se

Re: [go-nuts] Why is the method net.PacketConn.ReadFrom named as that? Isn't ReadInto more natural?

2018-10-07 Thread Jakob Borg
All the Read variants read into a buffer. The special thing about ReadFrom is that it tells you who the message was from. On 6 Oct 2018, at 18:06, T L mailto:tapir@gmail.com>> wrote: . -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To uns

Re: [go-nuts] Necessity of import constraints for golint

2018-10-13 Thread Jakob Borg
On 13 Oct 2018, at 00:57, Ian Lance Taylor mailto:i...@golang.org>> wrote: So, as a general rule, it's a good idea for any package to enforce that it is imported under a particular import path. I strongly disagree with this point. In my experience, import path comments are used to enforce the

Re: [go-nuts] pointer dereference optimization in loops

2018-11-30 Thread Jakob Borg
This should only be valid for a loop that doesn’t include any function calls, or if the compiler can prove that said function calls don’t involve any synchronization primitives anywhere in the possible call stack. So maybe it’s optimized in for … { total += *p } but I wouldn’t bet on it in

Re: [go-nuts] *Conn.Write() SSL doesn't detect closed socket/connection

2018-12-24 Thread Jakob Borg
This is the way of TCP sockets. “Write” means to put the bytes into the kernel send buffer and is essentially nonblocking within that buffer size. Connection errors are more often detected on the next read operation, which naturally blocks waiting for the next network event / packet. //jb On 2

Re: [go-nuts] missing fmt.Error(...interface{})

2018-12-30 Thread Jakob Borg
I would suggest that an error should start with a descriptive string. The existing methods encourage this. A fmt.Error as suggested would not, instead implicitly encouraging things like fmt.Error(false, 42) which is user unfriendly. //jb On 30 Dec 2018, at 09:53, Justin Israel mailto:justinis

Re: [go-nuts] Github independent issue tracker

2019-01-08 Thread Jakob Borg
On 8 Jan 2019, at 10:25, Jan Mercl <0xj...@gmail.com> wrote: Wrt the acceptable identity, I think one of the options is a GMail/Google account I hesitate to get involved in this discussion at all, but the world view where a Google tied identity is acceptable but a GitH

Re: [go-nuts] Github independent issue tracker

2019-01-08 Thread Jakob Borg
On 8 Jan 2019, at 11:11, Jan Mercl <0xj...@gmail.com> wrote: But the most important thing is that no one is suggesting "eschewing GitHub". The topic of this thread was listed in the OP: How to make it easy/easier for people without a MS account to contribute to the proj

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

2019-01-17 Thread Jakob Borg
On 16 Jan 2019, at 15:42, Victor Giordano mailto:vitucho3...@gmail.com>> 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" describ

Re: [go-nuts] multiple binaries from a single directory with go modules?

2019-01-20 Thread Jakob Borg
On 20 Jan 2019, at 20:20, Tycho Andersen mailto:ty...@tycho.ws>> wrote: That's how I have it now. The problem with this is that in the face of modules, it re-writes the go.mod and go.sum files to not include the deps of the binary it's not currently building, so you end up with a bunch of unneces

Re: [go-nuts] modules usage help

2019-04-01 Thread Jakob Borg
On 1 Apr 2019, at 11:22, T L mailto:tapir@gmail.com>> wrote: How to use this package in vgo mode? go mod init a.b.c/ddd go get github.com/projectcalico/libcalico-go@master The problem is that their latest non-prerelease tag is v1.7.3, wh

Re: [go-nuts] How to judge error in golang?

2017-08-02 Thread Jakob Borg
On 2 Aug 2017, at 20:40, yihao yang wrote: > > What is the philosophy in golang error? I also saw a lot of packages have > their own Error override error interface. Why there is no shared Error > structure with a shareable error code? > > 在 2017年8月2日星期三 UTC-7上午11:36:11,yihao yang写道: > Hi, > >

Re: [go-nuts] "find" for Slices like "append"

2017-08-08 Thread Jakob Borg
On 8 Aug 2017, at 09:06, martin.r...@programmfabrik.de wrote: > > So why not come up with > > func findFirst(slice interface{}, matches func(i int) bool) int > > or so? For what it's worth, it's not super difficult to implement this function once and for all if it's something that would make y

Re: [go-nuts] Repository of self-contained functions

2017-08-08 Thread Jakob Borg
On 7 Aug 2017, at 16:38, Lukas Senger wrote: > > Basically the idea is to > encourage writing and sharing simple self-contained functions. This sounds like a good thing, but in practice it gives you npm. //jb -- You received this message because you are subscribed to the Google Groups "golan

Re: [go-nuts] Arrays, structs and marshalJSON

2017-08-09 Thread Jakob Borg
On 9 Aug 2017, at 12:26, Sankar wrote: > > Now for the same, Item object, the json.Marshal function returns two > different strings for the `Item` object. > > If you run the playground url, you will find that: > > {"Items":[{"SD":"2009-11-10T23:00"}]} > {"Item":{"SD":"2009-11-10T23:00:00Z"}}

Re: [go-nuts] Returning a JSON object saved as a string in a database

2017-08-10 Thread Jakob Borg
On 10 Aug 2017, at 22:11, Dmitriy Cherchenko mailto:dcherche...@gmail.com>> wrote: What is the best way to send the stringified JSON object from the database as JSON and not as a string-type value of a property in the bigger JSON object the server is responding with? Do you mean like this? ht

Re: [go-nuts] memmove receives NULL src and positive length?

2017-08-15 Thread Jakob Borg
Have you run this code by the race detector? On 15 Aug 2017, at 17:01, bjorn.karge via golang-nuts wrote: > > Hello! > > I got this panic trace which I am trying to get my head around: > > panic: runtime error: invalid memory address or nil pointer dereference > [signal SIGSEGV: segmentatio

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

2017-08-16 Thread Jakob Borg
As far as I'm concerned, `defer resp.Body.Close()` is perfectly cromulent and there's no need to for error checking contortions to satisfy the lint tool. If we're talking about a http.Request I doubt that the close can ever fail (I haven't checked; but it doesn't seem like something that would m

Re: [go-nuts] Go 2 suggestion - what dependencies included in a build?

2017-08-16 Thread Jakob Borg
Keep in mind that you can't assume vcs info is available at build time. They may be building from a downloaded tarball, in which case you *may* have a Gopkg.lock (if everyone uses dep) but not much else. They may be Debian and build from source packages where the Go compiler sees no version info

Re: [go-nuts] From struct to map

2017-08-20 Thread Jakob Borg
This package: https://github.com/fatih/structs Or, more generally, reflection or code generation. For your specific struct I'd just add a method to return the map representation if that's what you need. //jb On 21 Aug 2017, at 06:42, Tong Sun mailto:suntong...@gmail.com>> wrote: To covert

Re: [go-nuts] Any idea why b.String() does not reflect the changes done in vim?

2017-08-21 Thread Jakob Borg
I'm not really sure what you're trying to do - the example appears to start vim on a file and then wait for it to exit, with nothing else happening. Are you interacting with vim manually in the meantime? Regardless, I bet the issue is that vim does not save the data to the same file - it saves

Re: [go-nuts] Making sense of Go profiling output

2017-08-23 Thread Jakob Borg
On 23 Aug 2017, at 10:00, Deepak Jois wrote: > > I am profiling a Go program that calls into C using cgo, and then > tries to get a pointer to unsafe data. In the profiling, I see that > over 62% of the time is spent in a call which is of the form > > func getBytes(val *C.MDB_val) []byte { >

Re: [go-nuts] Lazy Bash redirection

2017-08-26 Thread Jakob Borg
I think your best bet is to open a TTY manually when you detect that stdout is not a tty. You can use for example https://github.com/mattn/go-isatty to determine this. An `os.Open("/dev/tty")` might be enough, otherwise a package like https://github.com/mattn/go-tty shows some of the setup you m

Re: [go-nuts] Sort 3 pointers?

2017-08-28 Thread Jakob Borg
On 28 Aug 2017, at 13:13, Val wrote: > > To achieve this, I consider normalizing the triplet so that all keys of the > map verify > A < B < C > for some arbitrary definition of < . This ensures that I can detect any > Triangle already present as key in the map, regardless the order of its >

Re: [go-nuts] Sort 3 pointers?

2017-08-28 Thread Jakob Borg
hought of that when dismissing the > vertex struct inspection. Thanks! > > But it turns out that X,Y,Z will change often during my program execution: > vertices move, but their identity (and the triangles identity) must be > strongly preserved. > > On Monday, August 28, 2017 at

Re: [go-nuts] Unmarshal multiple similar XML Files

2017-08-31 Thread Jakob Borg
On 31 Aug 2017, at 09:30, Jeffrey Smith wrote: > > I'm trying to Unmarshal multiple XML files that have differing top level > elements but the rest of the document is identical. You can use the XMLName attribute for this: https://play.golang.org/p/4nIrfbaC37 //jb -- You received this messag

Re: [go-nuts] Same code different result?

2017-09-03 Thread Jakob Borg
Hi, It's not especially clear from your mail what your tool does, exactly. But assuming that it calculates hashes of content in some manner, my first guess would be that your test data character set and/or line endings get changed by the git checkin/checkout procedure. //jb > On 4 Sep 2017, a

Re: [go-nuts] Same code different result?

2017-09-04 Thread Jakob Borg
would not change regardless how you > are looking at it (unlike unicode), and the hashes is done on only words, > i.e., spaces and line endings will not affect the hashing. > > Thanks a lot for your help though, Jakob. > > On Mon, Sep 4, 2017 at 2:17 AM, Jakob Borg wrote: &

Re: [go-nuts] A question about evaluation of channel’s send statement

2017-09-06 Thread Jakob Borg
On 6 Sep 2017, at 10:28, T L wrote: > It is just weird that the evaluation timing of *p is different to other > expressions, such as, *p+0, *p*1, func()int{return *p}m etc. The value depends on a data race so it's entirely undefined in all cases. That the actual outcome then depends on trivial

Re: [go-nuts] Tools for 80 column split for golang

2017-09-06 Thread Jakob Borg
On 7 Sep 2017, at 06:10, Sankar wrote: > > Are there any tools available for golang to split long functions so that they > can fit in 80 columns (as long as possible) ? Don't fear longer lines, most of us are not on text mode terminals any more. :) When it becomes *too* long it's probably har

Re: [go-nuts] if condition in html template

2017-09-11 Thread Jakob Borg
The clean way to do this, in my opinion, is to make your item/element a type that knows whether it's failed or not. https://play.golang.org/p/K_t8iEZvUc You can also inject strings.Contains or similar using https://golang.org/pkg/html/template/#Template.Funcs //jb > On 11 Sep 2017, at 09:25,

Re: [go-nuts] Going crazy on golang maps

2017-09-23 Thread Jakob Borg
On 23 Sep 2017, at 15:27, Chris Polderman wrote: > > func (hue *HueBridge) pollSensors(sensors *sensors.Sensors) { >var previousSensorInfo map[int]sensors.Sensor = > make(map[int]sensors.Sensor) In your function declaration, you're declaring a parameter "sensors" of the type *sensors.Senso

Re: [go-nuts] Go get -f still checking VCS

2017-10-02 Thread Jakob Borg
The documentation for the -f flags says: > The -f flag, valid only when -u is set, forces get -u not to verify that > each package has been checked out from the source control repository > implied by its import path. This can be useful if the source is a local fork > of the original. However, you

Re: [go-nuts] Errors out of syscall

2017-10-02 Thread Jakob Borg
Presumably OP means that the actual type of the error is not exported and cant be type switched upon. However, the syscall errors are typically syscall.Errno and can be inspected for their numeric value, obviating the need to look at the string. It's rather platform specific though at that poin

Re: [go-nuts] Go get -f still checking VCS

2017-10-03 Thread Jakob Borg
On 3 Oct 2017, at 10:17, alexandre.ferri...@gmail.com wrote: > > Thanks. However, "go get -t" still complains about "missing Git command". > Indeed, on that machine I intentionally don't use any VCS (just a source > tarball). So I just need the Go compiler to compile and quit trying to brew >

Re: [go-nuts] Gomobile and SAF

2017-10-12 Thread Jakob Borg
On 12 Oct 2017, at 23:43, audrius.butkevic...@gmail.com wrote: > > Your example has a MainActivity.java. > As I said, this is a Go application, and as it stands it has no Java, so it > doesn't have (and doesn't intend to have) a main activity. > Also, your initialization (Hello.initContentProvide

Re: [go-nuts] Crypto - modes of operation

2017-10-13 Thread Jakob Borg
On 13 Oct 2017, at 14:40, Sonia Bogos mailto:soniam.bo...@gmail.com>> wrote: Hello, I have a small crypto question. I noticed that in the "crypto/cipher" package CBC and ECB are BlockMode type while CFB,CTR,OFB are Stream type. At the basics, they are all modes of operation that allow us to e

Re: [go-nuts] Re: Should you check error from ResponseWriter.Write()?

2017-10-22 Thread Jakob Borg
On 21 Oct 2017, at 21:20, "groenendaa...@gmail.com" mailto:groenendaa...@gmail.com>> wrote: And again, when might Write() return an error at all? For example if the client browser crashes, the user clicks "stop", or there is a network problem. //jb -- You rece

Re: [go-nuts] Re: Should you check error from ResponseWriter.Write()?

2017-10-22 Thread Jakob Borg
On 22 Oct 2017, at 17:29, "groenendaa...@gmail.com" mailto:groenendaa...@gmail.com>> wrote: So do you think this error should be checked and if yes, under what circumstances? I think Tamás already answered this. If you need to know whether the write succeeded a

Re: [go-nuts] Sanitising a UTF-8 string

2017-10-22 Thread Jakob Borg
Converting a string to a slice of runes gives you the individual code points, with the replacement character as necessary. Converting a slice of runes into a string gives you the UTF-8 representation. So sanitation of a string should be as simple as string([]rune(someString)). This will be O(n)

Re: [go-nuts] How to know if interface{} data is nil w/o reflecting?

2017-11-03 Thread Jakob Borg
I often do nil checks on interfaces in places like constructors that may or may not have received optional parameters. In some cases as a parameter that may be nil if no implementation is required, in some cases where a functional option setting the interface was not given. Typically this looks

Re: [go-nuts] Re: How to check if a request was cancelled

2017-11-08 Thread Jakob Borg
Errors from net/http are wrapped in an url.Error to contain information about the request that failed. You can unwrap it with an assertion or type switch; _, err := http.DefaultClient.Do(r) if urlErr, ok := err.(*url.Error); ok { log.Println(urlErr.Err == context.Canceled) // “true", in your exam

Re: [go-nuts] How to check if a request was cancelled

2017-11-08 Thread Jakob Borg
(expanding the code from the link) _, err := http.DefaultClient.Do(r) log.Println(err, ctx.Err() == context.Canceled) Note that, to be pedantic, this only tells you that the context has been cancelled - not that that was the error returned by the HTTP request. The HTTP request may have succeede

Re: [go-nuts] Efficient to copy Hash?

2017-11-08 Thread Jakob Borg
You can make it a teensy bit more efficient by copying the pointed-at value directly and skipping an allocation. (This isn’t safe in general but works for sha256.digest in this case.) I refactored away the string copies etc to focus on the actual hashing. https://play.golang.org/p/TxN2ni1o4v

Re: [go-nuts] Garbage collection and multi-purpose pointers

2017-11-12 Thread Jakob Borg
As you guessed, you can’t do this. You’re not allowed to store a pointer as uintptr for any time span longer than a single expression, essentially. Instead, have a real pointer (or interface) field that is nil when not used. //jb On 12 Nov 2017, at 16:49, gitul...@gmail.com

Re: [go-nuts] xml Unmarshal does not see expected type

2017-11-16 Thread Jakob Borg
You are setting an interface to a struct value, then passing Unmarshal a pointer to the interface. This is the wrong “order” of pointers and will result in Unmarshal overwriting the pointed to interface with the map. What you want to do is pass Unmarshal a pointer to your struct type: var x X{}

Re: [go-nuts] acme, letsencrypt and different HTTPS ports

2017-11-16 Thread Jakob Borg
The challenge method used by autocert only supports port 80 and 443. To use a different port you will need to use the dns-01 challenge method and the ACME client manually. On 17 Nov 2017, at 05:59, Sankar mailto:sankar.curios...@gmail.com>> wrote: Hi I have an EC2 vm where I want to run two g

Re: [go-nuts] Introspecting a type

2017-11-22 Thread Jakob Borg
A variable of type [][]Operation has that type and only that type. Your Concurrent and Sequential types are convertible to []Operation, and this is what happens in the assignment. You can probably use interfaces to accomplish what you want. type Operator interface { Operations() []Operation }

Re: [go-nuts] Interface value terminology

2017-11-27 Thread Jakob Borg
I’ve adopted terminology from other OO languages and people seem to have understood me. > 1. the value of an interface (both parts), This is the “interface value”. > 2. the concrete value, The “boxed value”. > 3. the type descriptor. No need to talk about it specifically. Worst case, it is "

Re: [go-nuts] Re: Why so many opt-out changes to test runs in 1.10?

2017-12-08 Thread Jakob Borg
On 8 Dec 2017, at 20:07, krun...@compliahealth.com wrote: > > I also agree with this. While the feature is great I would expect base > functionality changes to be opt-in. Go 1.10 in its entirety is opt-in. There’s plenty of time and opportunity to update build systems and processes before this

Re: [go-nuts] Combine low traffic website

2017-12-08 Thread Jakob Borg
On 8 Dec 2017, at 20:58, Gianguido Sorà mailto:g.so...@gmail.com>> wrote: You could run the two programs on the same vps by binding them to localhost and two different ports, and then use a reverse proxy (like nginx) to multiplex connections and add HTTPS. This way you can have one machine tha

Re: [go-nuts] Why so many opt-out changes to test runs in 1.10?

2017-12-08 Thread Jakob Borg
On 8 Dec 2017, at 20:20, Russ Cox mailto:r...@golang.org>> wrote: For test caching: For the record, I’ve used 1.10beta1 for all of about ten minutes now and it’s already transformed the way I work. I can now actually run the full test suite locally as part of editing and testing, as it takes

Re: [go-nuts] Understanding method pointers

2017-12-09 Thread Jakob Borg
I confess I find the code a bit convoluted and hard to follow - but doesn’t it just boil down to method values bound to the same pointer, thus acting on the same struct value (state)? https://play.golang.org/p/VVdSyaYp5x //jb On 9 Dec 2017, at 09:23, vik

Re: [go-nuts] github repo names with "go-" prefix?

2017-12-23 Thread Jakob Borg
On 23 Dec 2017, at 19:18, Tim Peoples wrote: > > I've noticed a somewhat common practice of people naming their github > repositories with a "go-" prefix (and then, of course, subsequently dropping > the prefix in the actual package name) -- yet a similar naming scheme doesn't > seem to be com

Re: [go-nuts] Possible bug on os.Stat and mode is symlink

2017-12-25 Thread Jakob Borg
You want os.Lstat. > On 25 Dec 2017, at 11:36, Shulhan wrote: > > Environment > > OS: Linux xenom-bubu 4.14.8-1-ARCH #1 SMP PREEMPT Wed Dec 20 21:27:44 > UTC 2017 x86_64 GNU/Linux > > Go: > - go1.10beta1 linux/amd64 > - go1.9.2 > > Steps to reproduce > > $ mkdir testSymlink > $ cd testSyml

Re: [go-nuts] Nil Channels and Case Evaluation

2017-12-31 Thread Jakob Borg
This has almost nothing to do with case statements or switches. Switch cases are expressions, expressions have a defined evaluation process. That process includes short circuiting boolean logic. Channel sends on the other hand have no such short circuiting, whether used in a select case or not.

Re: [go-nuts] Nil Channels and Case Evaluation

2017-12-31 Thread Jakob Borg
It would be much more odd, imho, for a select case to be chosen because a send can proceed, and for it then to block while generating the value to send. Simple politeness mandates that we have a value ready and evaluated when it becomes time to send it. //jb On 31 Dec 2017, at 16:41, dc0d mai

Re: [go-nuts] Pogreb - embedded key/value store for read-heavy workloads

2018-01-08 Thread Jakob Borg
On 8 Jan 2018, at 23:35, matthewju...@gmail.com wrote: sync.RWMutex works well as an embedded struct field. Locking DB could be db.Lock() instead of db.mu.Lock(), and the same could apply to other fields. This is a common suggestion. I’ve never been very fond of i

Re: [go-nuts] Writing to multiple addresses using net.UDPConn

2018-01-11 Thread Jakob Borg
On 11 Jan 2018, at 12:14, Adam Medziński mailto:adam.medzin...@gmail.com>> wrote: How should I create a net.UDPConn structure so I will be able to use WriteTo/WriteToUDP functions with different addresses? Connection created with net.DialUDP will not be right as it is in “connected” state and w

Re: [go-nuts] Chunked http response with go routines

2019-07-16 Thread Jakob Borg
At a guess, because your goroutine is running after the response handler has returned, and at that point the ResponseWriter isn’t valid any more. //jb On 16 Jul 2019, at 20:03, Hasan Genc mailto:hasangenc.istan...@gmail.com>> wrote: This is my original code. outside of the go routine w varia

[go-nuts] Odd runtime errors

2019-08-25 Thread Jakob Borg
Hi all, We develop an open source program for consumers that has a reasonably large usage within its niche, on a mix of operating systems and platforms. Recently we enabled crash reporting to get panic traces back from cooperating users. With that we've discovered a bunch of panics of our own c

Re: [go-nuts] How to execute a command using root?

2019-08-29 Thread Jakob Borg
On 30 Aug 2019, at 08:49, Benjamin mailto:wangchao.nlp@gmail.com>> wrote: Then I tried to use "sudo" to execute the command, but the environment variables can't be carried over into the command; This is a sudo configuration issue. See sudo --preserve-env etc. Best regards, Jakob -- You r

Re: [go-nuts] How to execute a command using root?

2019-08-31 Thread Jakob Borg
On 31 Aug 2019, at 12:33, Ronny Bangsund mailto:ronny.bangs...@gmail.com>> wrote: Digging through my vast mess of code, I found this function which sets the real and effective user (Setreuid) of the calling process: func DegradeToUser(uname string) error { Doesn't this suffer from the issue of

Re: [go-nuts] Re: go mod dependency hell is real

2019-09-13 Thread Jakob Borg
On 14 Sep 2019, at 01:52, anto...@aporeto.com wrote: but require 1.2.0 will not work if another dependency requires the same package at version 1.1.0 thanks to mvs. So either I'm wrong and I did not understand mvs, in that case I would like to get enlighten, or I got

Re: [go-nuts] Re: go mod dependency hell is real

2019-09-13 Thread Jakob Borg
On 14 Sep 2019, at 08:32, Antoine Mercadal wrote: > > Hey, > > Then why is it called mvs? I don't understand what package system would give > me 1.3.49, if I require 1.2.0 and my dependency requires 1.1.0. > > I'll read a bit more about it, but you may have decreased my level of go > module h

Re: [go-nuts] json time format discrepancy

2019-10-08 Thread Jakob Borg
On 8 Oct 2019, at 19:27, Andrey Tcherepanov mailto:xnow4fippy...@sneakemail.com>> wrote: In this case it loses subsecond precision, and it just bit me (doctor says I will live). Is it a bug or some historically-important reasons that I am missing are in play there? I don't see this discrepanc

Re: [go-nuts] rune vs (single code-point) string - size and printing

2016-08-22 Thread Jakob Borg
2016-08-22 17:50 GMT+02:00 JC : > which will be stored in a slice of type byte (which will use just one uint8 > in this case). You're probably already aware of this, but just for clarity since the "size" thing is part of subject and there is a comparison to the uint32, that string will require at

Re: [go-nuts] ListenAndServe without alert

2016-08-24 Thread Jakob Borg
2016-08-24 9:59 GMT+02:00 Joe Blue : > Would be curious to know what others think. Maybe there is still a way to > make it never show the alert on Windows I don't know Windows very well on this point, but I wouldn't be surprised if proper code signing made this go away. It does on Mac OS X at

Re: [go-nuts] Negative (BC) dates.

2016-09-06 Thread Jakob Borg
Year() returns an int, and the playground is 32 bit, so can't represent something smaller than about minus two billion. However if your use case is to represent times billions of years in the past I don't think a time.Time is the right type. There's the whole business about time zones, leap years a

Re: [go-nuts] Is there the incompatibility risk when using the XxxxPointer functions in sync/atomic package in later go versions?

2016-09-08 Thread Jakob Borg
tors 8 sep. 2016 kl 12:46 skrev T L : > > On Thursday, September 8, 2016 at 12:33:37 AM UTC+8, Ian Lance Taylor > wrote: > >> Perhaps you could explain what kind of compatibility risk you are >> concerned about that is not covered by the Go 1 compatibility >> guarantee. Please give an example of

Re: [go-nuts] Re: Assigning +Inf to a float32 ..

2016-09-11 Thread Jakob Borg
Exported variables can be changed, which is unnecessary to allow in this case. //jb On Sun, 11 Sep 2016 at 15:32, wrote: > > > On Sunday, 11 September 2016 14:25:29 UTC+1, Ian Lance Taylor wrote: > >> On Sun, Sep 11, 2016 at 6:06 AM, wrote: >> > >> > Also curious as why the implementation is

Re: [go-nuts] time.Time vs time.Instant

2016-09-21 Thread Jakob Borg
The sec and nsec fields in a time.Time are relative to the Unix epoch and so denote a point in time by themselves. The location is merely for presentation. ons 21 sep. 2016 kl 20:35 skrev 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com>: > Your Instant is not an Instant, it's a durat

Re: [go-nuts] time.Time vs time.Instant

2016-09-21 Thread Jakob Borg
Ah, indeed. No pedantry required to appreciate the difference, it's almost two thousand years after all. :) Sorry for the confusion. //jb ons 21 sep. 2016 kl 21:40 skrev Ian Lance Taylor : > On Wed, Sep 21, 2016 at 11:55 AM, Jakob Borg wrote: > > The sec and nsec fields in a

Re: [go-nuts] time.Time vs time.Instant

2016-09-21 Thread Jakob Borg
; doesn't seem worthwile to me and likely to cause more trouble than it has > advantages. > > On Wed, Sep 21, 2016 at 8:55 PM, Jakob Borg wrote: > >> The sec and nsec fields in a time.Time are relative to the Unix epoch and >> so denote a point in time by themselves.

Re: [go-nuts] fmt.Fscan without delimeter

2016-10-19 Thread Jakob Borg
You could, perhaps, use ioutil.ReadAll and then typeswitch for the common types (strings, []byte, the numerics) that you can easily handle. If the given receiver was not of one of those types, try to cast it to an encoding.BinaryUnmarshaler and/or encoding.TextUnmarshaler since that's essentially w

  1   2   >