[go-nuts] Gophercon 2019 videos?

2019-07-26 Thread gary . willoughby
With the recent Gophercon being held I wonder if any videos have been 
posted of the talks? I'm especially interested in the move to Go 2 and the 
plans for generics.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/087f893f-54ea-4692-8edf-34e22dd973a4%40googlegroups.com.


[go-nuts] Re: go modules and vendor: redundant features?

2018-11-22 Thread gary . willoughby
Vendor must be kept for when dependencies are no longer available online.

On Saturday, 17 November 2018 04:33:55 UTC, Henry wrote:
>
> Hi, 
>
> It seems to me that go modules and vendor attempt to solve the same 
> problem. I wonder whether we should just choose one and scrap the other, or 
> find a way to consolidate them under a single unified feature. I am a bit 
> concerned with the direction Go is going. People keep adding stuffs into Go 
> and later find themselves unable to remove existing features due to the 
> backward compatibility promise. Go 1.11 is a different beast than Go 1.0, 
> and is significantly more complex. 
>
> I think Go2 is an opportunity to learn from Go1, and to start from a clean 
> slate by scraping and consolidating features. Go2 needs to be simpler than 
> Go1.11
>
> Henry
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: non-standard json

2018-11-01 Thread gary . willoughby
If the file is consistent parse the Json part out of each line and just 
unmarshal it.

On Thursday, 1 November 2018 16:14:17 UTC, Alex Dvoretskiy wrote:
>
> Is there is a way to read a file line by line and extract JSON data from 
> it? 
>
>
> Example:
>
> file:
> `
> value1: {"field1": "123, "field2": "123"}
> value2: {"field1": "456", "field2": "879"}
> 
> `
>
> I need to extract the struct in a loop:
>
> type s struct {
> field1 string
> field2 string
> }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Regarding contracts

2018-10-24 Thread gary . willoughby
Maybe it's worth adding to: 
https://github.com/golang/go/wiki/Go2GenericsFeedback

On Tuesday, 23 October 2018 17:37:40 UTC+1, Burak Serdar wrote:
>
> I typed this up in a more organized way, and it turned out to be an 
> alternative declaration for contracts without touching the generics 
> parts of the proposal. 
>
> https://gist.github.com/bserdar/8f583d6e8df2bbec145912b66a8874b3 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How would Go 2 code using generics actually look like?

2018-10-23 Thread gary . willoughby
In that example, how would you call the `New` function?

On Monday, 22 October 2018 10:10:51 UTC+1, Sebastien Binet wrote:
>
> Hi Volker,
>
> On Mon, Oct 22, 2018 at 10:57 AM Volker Dobler  > wrote:
>
>> The Go 2 draft generics draft has been discussed a lot,
>> especially contracts have drawn a lot of attention and
>> other ways to limit the set of possible type were suggested.
>>
>> Most discussions orbited around very basic polymorphic
>> functions like polymorphic Min or a Map functions. I do consider
>> a polymorphic Min function to be nothing more than a
>> litmus test to generics: If a generic/polymorphic Min cannot
>> be written the proposal is insufficient. But I probably would
>> never write a polymorphic Min as a type specific Min is
>> 3 lines and basically impossible to get wrong and just because
>> Min looks nice under a proposal does not mean that the
>> proposed solution will lead to good code where generic or
>> polymorphic code would actually be beneficial: For complicated
>> data structures and algorithms.
>>
>> At least the original proposal mentions a generic Graph
>> data structure. Still without showing how e.g. DFS, BFS,
>> Shortest Paths would be a) implemented and b) used.
>>
>> I think it would be good if we could see how different proposals
>> (and especially the official one) would affect how generic code
>> is written and used. Especially code which is hard to get right
>> and really benefits from a "generic" implementation.
>>
>> I'd like to see generic/polymorphic:
>>  - Image manipulation (scaling, convolution, etc.) for various color 
>> models
>>  - Balanced trees (AVL or Red-Black)
>>  - Matrices of bool, int, float32/64, complex with inversion, 
>> LR-decomposition, eigenvalues
>>  - Fast Fourier Transformation (with ints, float32/64, complex64/128 and 
>> my float24 inputs)
>>  - Graph algorithms (DFS, BFS, Dijkstra, Bellman-Ford, Floyd-Warshall)
>> (feel free to add stuff from your field here).
>>
>> How would a package graph with a generic Graph data structure
>> and accompanying algorithms look like? How would I use such
>> a generic algorithm with nodes of my own type?
>>
>> How would I be using a generic 2d FFT package when my inputs
>> is complex128 and how if inputs are float32?
>>
>> I think that answers to these questions would be much more
>> helpful in evaluating generics than the current focus on the
>> syntax of Min and whether contracts can be done trough interfaces.
>>
>> Let's start with Dijkstra and the Graph example of the
>> original proposal: How would the implementation look like
>> and how would my code use this implementation?
>>
>
> I agree.
> I had started something like this, there:
> -  https://github.com/sbinet/go2-test/blob/master/ndarray/nd.go
> (my pet peeve is inter-operability with Python's protocol buffers and 
> NumPy n-dim arrays in particular)
>
> it would be great to have a code generator that takes e.g. Go-generics 
> draft-proposal code, and generates Go-1 compatible code (or, at the very 
> least a gofmt command that can make sure the code parses ok.)
>
> -s
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Having trouble installing golint

2018-10-17 Thread gary . willoughby
I'm having trouble installing golint. Any idea what the problem could be?

$ go get -u -v github.com/golang/lint/golint
github.com/golang/lint (download)
package github.com/golang/lint/golint: code in directory /home/gary/Code/go/
src/github.com/golang/lint/golint expects import "golang.org/x/lint/golint"

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: A concrete proposal re: using interfaces instead of contracts in Go 2 generics.

2018-10-11 Thread gary . willoughby
Add it to this: https://github.com/golang/go/wiki/Go2GenericsFeedback

On Wednesday, 10 October 2018 22:14:35 UTC+1, Ian Denhardt wrote:
>
> I've seen a lot of folks expressing the sentiment "we should just use 
> interfaces instead of this new contract thing." Most of the discussion 
> I've seen around this jumps right to operator overloading without being 
> terribly explicit about the general case; I've written a proposal 
> focusing on the latter: 
>
> https://gist.github.com/zenhack/ad508d08c72fce6df945a49945ad826d 
>
> (It is also linked from the feedback wiki page). 
>
> It punts on operator overloading, though discusses some related 
> subtleties. 
>
> Thoughts? 
>
> -Ian 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Where are the dependencies saved when we use go mod

2018-10-09 Thread gary . willoughby
You can also use the handy command `go mod download -json` to view 
information about the dependencies and where they are on disk for a module.

On Monday, 8 October 2018 22:29:46 UTC+1, ppras...@splunk.com wrote:
>
> Got it, Thanks Wagner.
> I did not set GOPATH since I was using GO111MODULE=on. Since I did not use 
> GOPATH I was having a doubt about its physical presence.
> But I found in the go root
>
> /Users/xxx/go/pkg/mod/cache
>
> Thanks Again.
>
>
> On Monday, October 8, 2018 at 2:21:00 PM UTC-7, Wagner Riffel wrote:
>>
>> > Where is the dependent github.com/stretchr/testify/assert downloaded - 
>> I dont see it downloaded any where. 
>> it still download physically, it's under $GOPATH/pkg/mod 
>> On Mon, Oct 8, 2018 at 5:55 PM pprasanthi via golang-nuts 
>>  wrote: 
>> > 
>> > I followed below steps to run tests in go mod. In this process I had 
>> few questions that needs clarification. 
>> > 
>> > cd /tmp/gomodtry/tests/src/hello/hello_test.go 
>> > package tests 
>> > 
>> > import ( 
>> > “github.com/stretchr/testify/assert” 
>> > “os” 
>> > “testing” 
>> > ) 
>> > 
>> > func GetEnv(key string, fallback string) string { 
>> > envVariable := os.Getenv(key) 
>> > if envVariable == “” { 
>> > return fallback 
>> > } 
>> > return envVariable 
>> > } 
>> > 
>> > func TestHello(t *testing.T) { 
>> > val := GetEnv(“check”, “ok”) 
>> > assert.Equal(t, “ok”, val, “val is not equal to ok”) 
>> > } 
>> > 
>> > func TestHello1(t *testing.T) { 
>> > val := GetEnv(“check”, “ok”) 
>> > assert.Equal(t, “ok”, val, “val is not equal to ok”) 
>> > } 
>> > 
>> > export GO111MODULE=on 
>> > 
>> > go test ./… 
>> > This created go.mod and go.sum files in cd /tmp/gomodtry/ location 
>> > When I executed go test ./… -v again , it executed the tests 
>> successfully. 
>> > 
>> > QUESTION: 
>> > 
>> > Where is the dependent github.com/stretchr/testify/assert downloaded - 
>> I dont see it downloaded any where. 
>> > Before go mod concept when we set GOPATH and then go get dependency, it 
>> used to download physically. 
>> > Can you please explain how the test is resolving dependency without the 
>> physical presence of dependent library. 
>> > 
>> > In previous version, when we go get dependencies, some times we used to 
>> get 500 error because the host where dependency exists will be down 
>> temporarily. 
>> > Do we still face this kind of issues with go mod concepts? How is it 
>> handled? [we did not like vendoring of dependencies, so we end up doing go 
>> get for every test run, which made of tests runs unstable when the host 
>> went down] 
>> > 
>> > -- 
>> > 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...@googlegroups.com. 
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: When using 'go mod vendor' why are there lots of files missing?

2018-09-24 Thread gary . willoughby
I think it's worth raising an issue for this. Vendoring should copy the 
whole repo.

On Monday, 24 September 2018 07:43:24 UTC+1, Justin Israel wrote:
>
>
>
> On Tuesday, September 18, 2018 at 8:58:01 AM UTC+12, Frits van Bommel 
> wrote:
>>
>>  According to the help text that's the intended behavior:
>>
>> usage: go mod vendor [-v]
>>>
>>> Vendor resets the main module's vendor directory to include all packages
>>> needed to build and test all the main module's packages.
>>> It does not include test code for vendored packages.
>>>
>>> The -v flag causes vendor to print the names of vendored
>>> modules and packages to standard error.
>>>
>>
>
> This just bit me, because it isn't copying required cc source files from a 
> parent directory of the package, leading to the cgo library not being able 
> to build:
>
> library
> cpp/
> source1.cpp
> go/
> lib.go
> inc.cpp
>
> For better or worse, inc.cpp has had '#include "../cpp/source1.cpp"' in 
> it, and it has been working under glide as the whole project gets vendored. 
> But now under "go mod vendor" it throws away the non-go files leading to 
> missing cpp files. Is this intended behaviour, expecting that the Go source 
> should have everything it needs as siblings or children in the directory 
> structure?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Examples testing with two newline, but only one newline

2018-08-13 Thread gary . willoughby
Your program doesn't work.

On Saturday, 11 August 2018 09:10:04 UTC+1, 子風 wrote:
>
> Hi
>
> https://play.golang.org/p/AIB-yJaExVu
>
> When I want to use examples to test my code, I find something odd.
> Example1 could pass, but Example2 failed
>
> --- FAIL: Example2 (0.00s)
>> got:
>> hello
>> .
>>
>> 123
>> want:
>> hello
>> .
>> 123
>> FAIL
>> exit status 1
>
>
> It seems Examples could only show one newline.
> Is there a solution to solve it? Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: How to signal(sigint) blocking goroutine

2018-08-09 Thread gary . willoughby
See this blog post for more interesting ways to handle goroutine 
communication and synchronization:

http://nomad.uk.net/articles/interesting-ways-of-using-go-channels.html

On Wednesday, 8 August 2018 04:59:48 UTC+1, natea...@gmail.com wrote:
>
> https://play.golang.org/p/d5n9bYmya3r
>
> I'm new to the go language and trying to figure out how to sigint a 
> blocking goroutine.  in the playground code I included an infinite for loop 
> to simulate the blocking. In my real world use the for block would be a 
> long running file save from an external device.  I appreciate any advice or 
> direction that is given.
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: How to signal(sigint) blocking goroutine

2018-08-09 Thread gary . willoughby
Just re-organise the code a bit, try 
this:  https://play.golang.org/p/GMpfZlCNP9G

On Wednesday, 8 August 2018 04:59:48 UTC+1, natea...@gmail.com wrote:
>
> https://play.golang.org/p/d5n9bYmya3r
>
> I'm new to the go language and trying to figure out how to sigint a 
> blocking goroutine.  in the playground code I included an infinite for loop 
> to simulate the blocking. In my real world use the for block would be a 
> long running file save from an external device.  I appreciate any advice or 
> direction that is given.
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Error getting FormValue in MultipartForm http request in Go 1.10

2018-05-18 Thread gary . willoughby
Maybe file an issue here?:
https://github.com/golang/go/issues

On Friday, 18 May 2018 13:55:00 UTC+1, Sergey Mosalov wrote:
>
> Hi!
> In version 1.9, I had no problem getting the FormValue in http request.
> After upgrading to version Go 1.10 of FormValue is empty. Did I find the 
> error? in module:
> mine/multipart/formdata.go
> *before*:
> _, hasContentTypeHeader := p.Header["Content-Type"]
> if *!*hasContentTypeHeader && filename == ""
> *after*
> _, hasContentTypeHeader := p.Header["Content-Type"]
> if hasContentTypeHeader && filename == ""
> began to work as I need
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: It was removed some packages from go.googlesource.com

2018-04-24 Thread gary . willoughby
OMG I didn't realize that repo had gone. I need to update some of my 
projects. Christ sake!!!

On Tuesday, 24 April 2018 16:42:33 UTC+1, thec...@netflix.com wrote:
>
> Hey Gary,
>
> This isn't a leftpad moment. Your code can still be compiled, and there's 
> a not too invasive workaround:
>
> - https://github.com/golang/lint/issues/397#issuecomment-383752949
>
> Our leftpad moment was a few months ago when this repo disappeared:
>
> - https://github.com/jteeuwen/go-bindata
> - https://github.com/jteeuwen/go-bindata/issues/5
>
> Cheers!
> -Tim
>
> On Tuesday, April 24, 2018 at 8:33:46 AM UTC-7, 
> gary.wi...@victoriaplumb.com wrote:
>>
>> This is Go's leftPad moment. Dependency management is a complete joke in 
>> Go!
>>
>> https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/
>>
>> On Monday, 23 April 2018 14:58:55 UTC+1, takanao ENDOH wrote:
>>>
>>> Hi, guys.
>>>
>>> Could not `go get golang.org/x/lint/golint` 
>>> .
>>> Is it working normally?
>>>
>>> Seems it was removed some packages from https://go.googlesource.com/ .
>>>
>>> webcache:
>>>
>>> http://webcache.googleusercontent.com/search?q=cache%3Ago.googlesource.com%2F
>>>
>>> Thanks for your checking.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: It was removed some packages from go.googlesource.com

2018-04-24 Thread gary . willoughby
This is Go's leftPad moment. Dependency management is a complete joke in Go!

https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/

On Monday, 23 April 2018 14:58:55 UTC+1, takanao ENDOH wrote:
>
> Hi, guys.
>
> Could not `go get golang.org/x/lint/golint` 
> .
> Is it working normally?
>
> Seems it was removed some packages from https://go.googlesource.com/ .
>
> webcache:
>
> http://webcache.googleusercontent.com/search?q=cache%3Ago.googlesource.com%2F
>
> Thanks for your checking.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-29 Thread gary . willoughby
Thanks for the all the responses but I was after a more dynamic solution 
where you don't need to 'register' the types or select them using a switch 
but that it just works.
For example, to support new types (like the PHP code) I was hoping you 
could just add the structs and no more changes to the code base, it just 
magically supports any new Json types.

I was going down this route:

package main


import (
"fmt"
"go/importer"
"os"
"reflect"
"unsafe"
)


type dummyInterface struct {
_  uintptr
_  uint64
_  [3]uintptr
StrPtr *string
}


var rules map[string]reflect.Type


func init() {
rules = make(map[string]reflect.Type)


pkg, err := importer.Default().Import("test/rule")
if err != nil {
fmt.Printf("error: %s\n", err.Error())
os.Exit(1)
}


for _, typeName := range pkg.Scope().Names() {
name := "rule." + typeName
var rule interface{} = {
StrPtr: ,
}
typ := reflect.TypeOf(*(*interface{})(unsafe.Pointer()))
rules[name] = typ
}
}


func main() {
for _, r := range rules {
c := reflect.New(r)


fmt.Printf("%#v\n", c.Elem())
}
}

This code currently doesn't work but you can see where I was going. I only 
had a small measure of success (in some iterations I did get it working) 
and the more I try to make this work I realise it's going too far.
I think a simple switch is much more in keeping with Go.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread gary . willoughby
Thanks. I read that blog post earlier and presents two different ways of 
handling this. Each maintains a list of switch cases and constants 
respectively so still not entirely dynamic.

I'll probably just go with a switch then.

On Wednesday, 28 March 2018 13:25:47 UTC+1, Andrei Tudor Călin wrote:
>
> It isn't really possible to do so because there is no nice and type safe 
> way of getting from a string in the JSON to a Go type,
> and a value of said type. You must write a little bit of extra code.
>
> This article: http://eagain.net/articles/go-dynamic-json/ presents a good 
> approach.
>
> On Wednesday, March 28, 2018 at 1:46:24 PM UTC+2, 
> gary.wi...@victoriaplumb.com wrote:
>>
>> Is it possible to unmarshall Json by selecting the struct from a field in 
>> the Json?
>>
>> I'm porting some PHP code to Go and this is something I may have to 
>> approach differently.
>> Here is the Json:
>>
>> [
>> {
>> "class": "Domain\\Model\\Message",
>> "skus": [
>> "FOO1"
>> ],
>> "label": "Lorem",
>> "text": "Lorem ipsum dolor sit amet.",
>> }
>> ]
>>
>> In PHP the above Json is decoded into an associative array and I can use 
>> the 'class' field to decode further to an object (dynamically selecting the 
>> object using the 'class' value), like this:
>>
>> $obj = $decoded['class']::jsonDeserialize($decoded);
>>
>>
>> assert($obj->label == "Lorem");
>>
>> So the above really translates to calling the static method on a concrete 
>> class, like this:
>>
>> $obj = Domain\\Model\\Message::jsonDeserialize($decoded);
>>
>> Can I do anything similar in Go without using a switch defining separate 
>> unmarshalling for each class?
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Is it possible to unmarshall Json by selecting the struct from a field in the Json?

2018-03-28 Thread gary . willoughby
Is it possible to unmarshall Json by selecting the struct from a field in 
the Json?

I'm porting some PHP code to Go and this is something I may have to 
approach differently.
Here is the Json:

[
{
"class": "Domain\\Model\\Message",
"skus": [
"FOO1"
],
"label": "Lorem",
"text": "Lorem ipsum dolor sit amet.",
}
]

In PHP the above Json is decoded into an associative array and I can use 
the 'class' field to decode further to an object (dynamically selecting the 
object using the 'class' value), like this:

$obj = $decoded['class']::jsonDeserialize($decoded);


assert($obj->label == "Lorem");

So the above really translates to calling the static method on a concrete 
class, like this:

$obj = Domain\\Model\\Message::jsonDeserialize($decoded);

Can I do anything similar in Go without using a switch defining separate 
unmarshalling for each class?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Is there any ways to kill goroutine immediately ?

2018-01-11 Thread gary . willoughby
A `return` should kill it.

On Thursday, 11 January 2018 15:50:24 UTC, Iman Tumorang wrote:
>
> I'm using goroutine with 2 concurrent jobs. 
>
> And I've using context with both of the goroutine. 
>
> I use  
> context.WithTimeout
>
>
> func (u *feedUsecase) fetchDataWithContext(ctx context.Context, location 
> string, fc chan feedChan) {
>   go func() {
>  for {
>select {
>case <-ctx.Done():
> fc <- feedChannel{
> Err: ctx.Err,
> Data: nil,
> }
> return 
> default:
> // Calling another API
> fc <- resultFromAPI
> return
> }
> }
>
>
>
> I've succeeded to stop the waiting for the response of the function that 
> uses the goroutine.
>  And returning the error: context exceeded. But later I found that the 
> goroutine still exists until it's finished the process. 
>
>
> Is there any ways to kill immediately the goroutine??
>
> I mean, some tricks or ways to kill all the process immediately in 
> function : fetchDataWithContext
>
>
> Thank you.
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Go Code Debugging

2017-11-22 Thread gary . willoughby
I think it's a nightmare to set Eclipse up to support Go. Here's a 20 
minute tutorial:

https://www.youtube.com/watch?v=v6Wn5gUSEwM

If you fancy swapping editor, try Visual Studio Code. It's Go support is 
second to none (just install the Go plugin and you're done) and has 
excellent debugging support.

On Wednesday, 22 November 2017 13:28:39 UTC, shanthku...@gmail.com wrote:
>
>
>
> Hi Go Experts,
>
>  Could you please share steps to debug go code using breakpoints in 
> eclipse?
>
>  Does it requires any third party tool.?
>
>
> *Thanks and Regards*
> *Shantkumar.S*
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Perfomance - sha256 Encoding to Hex

2017-10-17 Thread gary . willoughby
There are syntax errors in your code.

On Tuesday, 17 October 2017 09:13:41 UTC+1, Christian LeMoussel wrote:
>
> I need to calculate 10 millions of  sha256 checksums, 
>
> Actually I do this :
>
> var bl int
> var pnb = make([]byte, 10)
> var hash = [32]byte
> var sha256Hash string
> var steps = 1000
>
> startBench := time.Now()
>
> for i := 0; i < steps; i++ {
> bl = 0
> bl += copy(pnb[bl:], "TEST")
> bl += copy(nonce[bl:], fmt.Sprintf("%04x", i))
> bl += copy(pnb[bl:], "00")
> hash = sha256.Sum256(pnb)
> sha256Hash = hex.EncodeToString(hash[:])
> }
>
> elapsedBench := time.Since(startBench)
>
> log.Printf("%d iterations => sha256 took %v", steps, elapsedBench)
>
> Is it possible to improve the speed?
>
> Thank for your help
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Building golang libraries

2017-09-29 Thread gary . willoughby
You could try plugins:

https://golang.org/pkg/plugin/

On Friday, 29 September 2017 05:21:54 UTC+1, Abhijit Desai wrote:
>
> Want to create libraries ( static or dynamic ) so that that I don't want 
> to compile every time when I build my executable
>
> "github.com/everjit/Ion" <--- should not refer to code rather it should 
> refer to build library like .so or .dll ( in windows ) and will provide 
> that to go build command line.
>
> package main
>
> import (
> "github.com/everjit/Ion"
> "strings"
> }
>
> func main(){
> Ion.Invoke()
> }
>
> Please help
>
> Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Generics and readability

2017-08-24 Thread gary . willoughby
Using D syntax:

func (r MyType) foo(A, B)(x A, y B) (z B, err error) {
...
}

result, _ := MyType.foo!(int, int)(10, 20)

Also, there's no reason why A and B can't be inferred:

result, _ := MyType.foo(10, 20)

It looks alright to me and very useful!


On Thursday, 24 August 2017 16:14:58 UTC+1, JuciÊ Andrade wrote:
>
> A lot of people like Go because code is very readable even for beginners.
>
> func f(x, y int)
>
> f is a function that receives x and y as int parameters, returning 
> nothing. Simple enough.
>
> func f(x, y int) int
>
> f is a function that receives x and y as int parameters, returning yet 
> another int. Fine.
>
> func f(x, y int) (z int, err error)
>
> f is a function that receives x and y as int parameters, returning two 
> values: a first int, that we name z and an error named err. A little bit 
> weird, but ok.
>
> func (r MyType) f(x, y int) (z int, err error)
>
> f is a method for a value of type MyType, henceforth named r, that 
> receives x and y as int parameters, returning two values: a first int, that 
> we name z and an error named err. Definitely not so simple.
>
>  func (r genType1) f(x, y genType2) (z getType2, err 
> error)
>
> You must be kidding. STOP RIGHT THERE!
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-06-02 Thread gary . willoughby
Right, now show me the contents of the *average wage by country *function! 
It's not going to be one line or as readable is it?!?!

On Friday, 2 June 2017 14:26:47 UTC+1, Egon wrote:
>
> On Friday, 2 June 2017 15:59:41 UTC+3, gary.wi...@victoriaplumb.com wrote:
>>
>> Generics enable more than just replacing loops. For example, they can 
>> enable libraries of generic algorithms to be used with any type of array. 
>> Here's an example:
>>
>> foo := GetArray()
>> result := foo.Take(10).map(...).Sort(...).Reduce(...)
>>
>
> Why stop there? It also could be:
>
> *result := average wage by country*
>
> This is much more readable than the map/reduce stuff. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Weird performance with exp/shiny

2017-04-28 Thread gary . willoughby
I'm just guessing but I don't think the emulated version is faster, just 
that it is not being throttled. Usually, when creating games or demos there 
is a throttle in the code to stop the main loop from executing as fast as 
it can. It looks like this is being respected on Mac but not in the 
emulator. My guess would be something in the event package is doing this.

On Friday, 28 April 2017 03:28:10 UTC+1, Zellyn wrote:
>
> I'm sure I'm doing something hideously wrong with shiny, since my emulator 
> runs three times faster on my MacBook if I run it under VirtualBox/Ubuntu. 
> Yes, you read that right.
> Here, I tweeted an animated gif of them running side by side: 
> https://twitter.com/zellyn/status/857674501928222720
>
> I ripped out the emulator code and made it simply plot a pixel each frame. 
> Here's the result, which still runs much faster under a virtual machine: 
> https://play.golang.org/p/par16HK1X2
>
> I'm sure I'm doing the wrong kind of texture update / buffer copy / 
> something wrong. Please, educate me! Extra points for explaining enough to 
> us all that we could understand what's actually going on.
>
> Thanks,
>
> Zellyn
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Turning unicode code string to rune

2017-04-24 Thread gary . willoughby
See: https://golang.org/pkg/unicode/utf8/#DecodeRuneInString

On Saturday, 22 April 2017 19:51:09 UTC+1, Tong Sun wrote:
>
> Hi, 
>
> Given a unicode code string, be it "4e16", or "0x4e16", or "u4e16", how to 
> turn it into a single char rune?
>
> You can finish the code at https://play.golang.org/p/AFIEz3eJVz
>
> Thanks. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Algorithm Club

2017-03-28 Thread gary . willoughby
Parametric polymorphism is enabled by generics.

On Friday, 24 March 2017 19:16:24 UTC, Rob 'Commander' Pike wrote:
>
> Algorithms are not helped by generic types as much as by polymorphism, a 
> related but distinct subject.
>
> -rob
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: casting slice of rune to string picks up extra characters for some inputs

2017-03-03 Thread gary . willoughby
Go strings are UTF-8 encoded as others have mentioned. This means that each 
human readable character in the string is really a cluster of one or more 
runes. Some characters are made up of one rune, some are made up of many. 
Some runes combine with others to create different characters. Also, runes 
don't have a preset size in bytes, some are made up of one byte, others are 
made up of more.

In your example, the character © is made up of one rune, which is defined 
using two bytes, each with the values 0xc2 and x0a9 respectively.

On Tuesday, 28 February 2017 17:29:07 UTC, Fraser Hanson wrote:
>
> https://play.golang.org/p/05wZM9BhfB
>
> I'm working on some code that reads UTF32 and converts it to go strings. 
> I'm finding some surprising behavior when casting slices of runes to 
> strings.
>
>  runes := []rune{'©'}
>  fmt.Printf(" cast to string: (%s)\n", string(runes))
>  fmt.Printf("bytes in string: (%x)\n", string(runes))
> Output:
>
>  cast to string: (©)
> bytes in string: (c2a9) // <-- where's the C2 byte coming from??
>
>
> The weird part is that casting the rune slice to a string causes it to 
> pick up an additional leading character. 
>
> runesi 0x00-0x7f get nothing prepended.
> runes 0x80-0xbf gets a leading c2 byte as seen above.
> runes 0xc0-0xff gets a leading c3 byte.
> rune 0x100 gets a leading c4 byte.  Seems like a pattern here.
>
> The same thing happens if I add the runes into a bytes.Buffer with 
> WriteRune(), then print it out with bytes.Buffer.String().
>
> Can anyone explain this?  
> What's the correct way to convert a slice of runes into a string?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Problems drawing on frames of an animated gif

2017-02-06 Thread gary . willoughby
Thanks!

On Sunday, 5 February 2017 01:25:21 UTC, Nigel Tao wrote:
>
> On Mon, Jan 23, 2017 at 6:03 AM, kalekold via golang-nuts 
>  wrote: 
> > Hmm.. the source gif I'm using must be compressed. Doesn't Go handle 
> > compressed gifs in the same way? When you say 'I may get unexpected 
> results' 
> > is that because the current gif package doesn't support compression? 
>
> A GIF image is a sequence of frames. Some frames are complete 
> pictures, some frames contain only those pixels that changed from the 
> previous frame. (If you're familiar with video formats like MPEG, you 
> might recognize these concepts as I-frames and P-frames). 
>
> The second type of frame, delta frames or P-frames, often encode much 
> smaller since they're often mostly transparent, and so are sometimes 
> called "compressed" GIFs. Both sorts of frames also use LZW 
> compression, but that's probably not what we're discussing here. 
>
> The Go image/gif package supports complete and delta frames. As per 
> the GIF spec (http://www.w3.org/Graphics/GIF/spec-gif89a.txt), the 
> package calls this the disposal method. Support means that decoding a 
> GIF image will give you the per-frame disposal methods, and passing a 
> slice of per-frame disposal methods to Encode will produce a well 
> formatted GIF. 
>
> However, the package does not apply the deltas to previous frames for 
> you. If you want to load an animated GIFs and replace some frames, it 
> is up to the user of the image/gif package (i.e. you) to apply the 
> deltas when decoding, or re-calculate the deltas when encoding. Or you 
> can set decoded.Disposal[i] to gif.DisposalNone to change the frame 
> from a P-frame to an I-frame, but that might lead to a larger GIF 
> file. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: How has your company adopted Go ?

2016-12-19 Thread gary . willoughby
It should always be 'use the best tool for the job'. If Go seems like a 
good fit for a task, use it. We've used Go for creating web services 
accessed via restful API's and it works great. I've personally used Go to 
create command line utilities to help with development. We've also used it 
to prototype systems before using other languages.

We don't see it as a risk but as a competitive advantage.

On Monday, 19 December 2016 13:03:43 UTC, Tieson Molly wrote:
>
> What arguments or factors have contributed to your company adopting Go?
>
> Many businesses see switching to a new language or even using a new 
> language side by side with their existing  language choice as a business 
> risk.
>
>   Best regards,
>
>   Ty
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: printf in color

2016-11-07 Thread gary . willoughby
https://godoc.org/?q=terminal+color

On Friday, 1 February 2013 23:02:04 UTC, Constantine Vassilev wrote:
>
> I am printing a lot lines in command line during testing.
> Visualizing using a color would be great.
>
> Are there a way to send color related commands to the terminal using* 
> printf*?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Ignoring UTF-8 BOM when decoding JSON

2016-09-23 Thread gary . willoughby
Yeah, the Json decoder should handle it. Maybe post a bug report? 
 https://github.com/golang/go/issues

On Friday, 23 September 2016 15:21:13 UTC+1, Mark Richman wrote:
>
> This works great, thanks! https://github.com/spkg/bom 
>
> Agreed, JSON should not have BOM, however there is still software out 
> there, especially on Windows, which insist on writing out JSON with the 
> BOM. So, I have to account for it, standard or not.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Ignoring UTF-8 BOM when decoding JSON

2016-09-23 Thread gary . willoughby
This looks like a compounded error.

First, Json should never have a BOM encoded within it. Second, it seems 
like the Go Json decoder doesn't account for the BOM if it is mistakenly 
encoded. Both are mentioned in the Json RFC: 
https://tools.ietf.org/html/rfc7159#section-8.1

On Friday, 23 September 2016 12:37:56 UTC+1, Mark Richman wrote:
>
> I have a JSON file which begins with the UTF-8 byte-order marker (BOM) 
> 0xEF 0xBB 0xBF.
>
> This causes Decode() to fail with SyntaxError:
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Static race detector?

2016-09-13 Thread gary . willoughby
You might be interested in this:

Golang UK Conference 2016 - Nicholas Ng - Static Deadlock Detection for Go:
https://www.youtube.com/watch?v=NOQdkbp-950

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Request to backport OSX Sierra fix in 1.6.4

2016-09-09 Thread gary . willoughby
Purely out of interest, why not upgrade to v1.7.1?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Small complete examples which show the power of Go?

2016-08-10 Thread gary . willoughby
Hi,

I'm giving a talk at work introducing Go and I'm looking for small examples 
to show Go's potential. For example, the following program demonstrates a 
bare-bones webserver in 13 lines:

import (

"fmt"
"net/http"
)
 
func home(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, world!")
}
 
func main() {
http.HandleFunc("/", home)
http.ListenAndServe(":8080", nil)
}

Has anyone here got any more little snippets like this to show the power 
and potential of Go? It doesn't have to be in networking, just little a 
little snippet to make people think "wow, that's cool!".

Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.