[go-nuts] How to compare two network addresses (stringifyed or not) for equality?

2017-06-03 Thread 'Константин Иванов' via golang-nuts
Here is a code: package main import ( "fmt" "log" "net" ) func main() { l, err := net.Listen("tcp", "[::]:9090") if err != nil { log.Fatal(err) } defer l.Close() go func() { for { l.Accept() } }() c, err :=

[go-nuts] Re: Confusing type rules

2017-06-03 Thread xiiophen
To answer the first point - the keyword is "*assignable*" here - an slice []int{1,23} is not assignable to a slice []I where I is a type of int. See https://golang.org/ref/spec#Assignability ( also golang treats slices as types in themselves ie https://golang.org/ref/spec#SliceType )

[go-nuts] Confusing type rules

2017-06-03 Thread conrad via golang-nuts
Hey nuts! I ran into the following confusion today: https://play.golang.org/p/XH8wyj6IbT. Consulting the golang spec, I think this is correct. `If the final argument is assignable to a slice type []T, it may be passed unchanged as the value for a ...T parameter if the argument is followed by

[go-nuts] [Feedback] Create JSONSchema Validator

2017-06-03 Thread santhosh . tekuri
Hi, https://github.com/santhosh-tekuri/jsonschema I created JSONSchema Validator in GO. It implements Draft4 and passes all tests including optional one in https://github.com/json-schema/JSON-Schema-Test-Suite Looking for feedback. Let me know if you find this useful. Thanks Santhosh Kumar

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

2017-06-03 Thread Egon
On Saturday, 3 June 2017 13:11:04 UTC+3, mhh...@gmail.com wrote: > > Hi, > > yes generics / not generics. > > That is, in what i proposed, only the consumer is enhanced, thus generics > are not required anymore on the declarer, except for this conv method, > indeed. > > also as the declarer can

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

2017-06-03 Thread mhhcbon
for the fun, with early return, https://play.golang.org/p/I9AORKOYQm On Saturday, June 3, 2017 at 12:34:15 PM UTC+2, mhh...@gmail.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. >

[go-nuts] gob's interpreted machine

2017-06-03 Thread Santhosh Ram Manohar
>From https://blog.golang.org/gobs-of-data "The first time you encode a value of a given type, the gob package builds a little interpreted machine specific to that data type. It uses reflection on the type to construct that machine, but once the machine is built it does not depend on

Re: [go-nuts] CGO & Plugins

2017-06-03 Thread Nick Groenen
On 2017-06-02 19:24:40, Michael Brown wrote: Do you have any references on the stability of the current plugin system that I can use for reference? I'm building a system now that I contemplate using with some plugins and I'd like to know up front the challenges. I wrote a blogpost on plugins

[go-nuts] Re: Golang, SQL and ORM avoidance techniques

2017-06-03 Thread silviucapota
Hi Adam, Back in 2014 I had the same driving motives like you and I ended up writing my own generator for Postgres (to deal with tables, views, and functions, for the basic types): https://github.com/silviucm/pgtogogen

Re: [go-nuts] [ERROR] invalid argument when executing bufio.NewWriter.Flush()

2017-06-03 Thread Harry
Thanks Jan! You are great! On Saturday, 3 June 2017 13:00:51 UTC+2, Jan Mercl wrote: > > On Sat, Jun 3, 2017 at 12:42 PM Harry > wrote: > > > How can I handle to write something out using bufio.NewWriter? > > Just fine. The problem is you haven't created any file to write

Re: [go-nuts] [ERROR] invalid argument when executing bufio.NewWriter.Flush()

2017-06-03 Thread Jan Mercl
On Sat, Jun 3, 2017 at 12:42 PM Harry wrote: > How can I handle to write something out using bufio.NewWriter? Just fine. The problem is you haven't created any file to write to in the first place, which checking the error could have told you. -- -j -- You received this

[go-nuts] [ERROR] invalid argument when executing bufio.NewWriter.Flush()

2017-06-03 Thread Harry
Hi guys, How can I handle to write something out using bufio.NewWriter? My code is like below, var writer *bufio.Writer var err error file, _ := os.OpenFile(*fileName, os.O_WRONLY | os.O_APPEND, 0644) defer file.Close() writer = bufio.NewWriter(file)

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

2017-06-03 Thread mhhcbon
> 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: in my demonstration every type got this kind of method, the problem become how do you jump from Type A to type B. in []A to []B or

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

2017-06-03 Thread mhhcbon
yes true. I m not sure i intend to change that asap, but this another topic, i want not deep into right now. That being said again agreed, understood, prone to happen, maybe. On Friday, June 2, 2017 at 12:05:52 PM UTC+2, Egon wrote: > > On Friday, 2 June 2017 12:06:54 UTC+3, mhh...@gmail.com

[go-nuts] CGO & Plugins

2017-06-03 Thread Cristian Măgherușan-Stanciu
The best real world example I know of mixing cgo and plugins is https://github.com/eawsy/aws-lambda-go-shim and it works pretty well. It compiles a go program as a native library using cgo, which is loading some more golang code compiled as a plugin. The native library also happens to

[go-nuts] filago: Monitor a Linux process' opening and closing of files, including Unix pipes and sockets

2017-06-03 Thread Dave Cheney
fuser(1) will tell you for a file netstat(1) -anp will do for sockets -- 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.

[go-nuts] filago: Monitor a Linux process' opening and closing of files, including Unix pipes and sockets

2017-06-03 Thread ChrisLu
Thanks! This should be very useful. Sometimes I want to know the inverted answer that which process is using a port or a 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,

[go-nuts] Copy map with empty interfaces

2017-06-03 Thread Tamás Gulácsi
How is cgo involved here? What kind of keys are you using? -- 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