Re: [go-nuts] Please help me solve a bug with my licencing system!

2018-05-10 Thread Burak Serdar
It is likely that HashDecoded is "" (line 28) because hex.DecodeString() fails, so password check never fails. On Thu, May 10, 2018 at 7:46 PM, wrote: > Hello all, > > I am creating a simple licencing system to help licence my own programs and > also to help others via

Re: [go-nuts] Performance hit when using goroutine

2018-05-22 Thread Burak Serdar
get multiple db connections instead of using a shared one. If your db driver is serializing concurrent operations on the same connection, the goroutines would run sequentially, which seems to be the case. > > On Tuesday, May 22, 2018 at 12:36:25 PM UTC+7, Burak Serdar wrote: >

Re: [go-nuts] Why doesn't this select statement timeout?

2018-05-21 Thread Burak Serdar
On Mon, May 21, 2018 at 12:13 PM, wrote: > timeout := 1 * time.Millisecond > select { > case ch <-f(req): > case <-time.After(timeout): > ch <- errors.New("timeout") > } The instant 'select' is evaluated, ch is writable. Also time.After() is called, and returns a

Re: [go-nuts] Performance hit when using goroutine

2018-05-21 Thread Burak Serdar
On Mon, May 21, 2018 at 11:12 PM, Hawari Rahman wrote: > Hi Everyone, > > So for the background, I have an API for retrieving data from a database. > For an endpoint there exists two function calls: > - SelectCollections - for retrieving the collection records > -

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: > > > > // now > env := make(map[string]string) > for _, e := range os.Environ() { > sep := strings.Index(e, "=") > env[e[0:sep]] = e[sep+1:] > } > // how to add env into data as ENV so that it can be accessed within

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 9:32 AM, Tong Sun <suntong...@gmail.com> wrote: > Thanks. but, > > On Wed, May 2, 2018 at 11:27 AM, Burak Serdar wrote: >> >> On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: >> > >> > >> > >> > // now >>

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 5:18 PM, Tong Sun wrote: > > > On Wed, May 2, 2018 at 12:06 PM, Jan Mercl wrote: >> >> >> Ugly hack, completely wrong in the general case: >> https://play.golang.org/p/IM_lxT3PxmR > > > Oh, I now know why it was called "hack", because the thing would

Re: [go-nuts] Question about int inside json

2018-04-28 Thread Burak Serdar
On Sat, Apr 28, 2018 at 12:04 PM, wrote: > > Hallo all, > > I've a "stupid" question about the type "int" when used inside json. > Almost every documentation I've found says int is 32 bit long, so that I > expect a range from -2.147.483.648 to 2.147.483.647. int is 32 bits

Re: [go-nuts] Map with multiple "indexes"

2018-01-10 Thread Burak Serdar
On Wed, Jan 10, 2018 at 7:57 AM, wrote: > I'm trying to come up with a data structure that I can search for map values > quickly without having to iterate an entire (and large) map to find a value. > > Essentially I have a map that contains lots of data and the key is the >

Re: [go-nuts] Map with multiple "indexes"

2018-01-10 Thread Burak Serdar
1(s string) { if v, ok:=m.f1Map[s]; ok { delete(m.f1Map,s) delete(m.f2Map,v.Field2) } } > > On Wednesday, January 10, 2018 at 3:24:37 PM UTC, Burak Serdar wrote: >> >> On Wed, Jan 10, 2018 at 7:57 AM, <l...@pinkfroot.com> wrote: >> > I'm trying to come up wi

Re: [go-nuts] Web Framework for Beginners

2018-01-24 Thread Burak Serdar
Revel is a good one. https://revel.github.io/ On Wed, Jan 24, 2018 at 6:49 AM, pradam wrote: > Hi Gophers, > > As for Newbie to Go.I am excited to learn a web framework but I don't know > where to start please help me out by suggesting a good framework for >

Re: [go-nuts] Re: Updating specific elements of a big json file.

2018-01-11 Thread Burak Serdar
On Jan 11, 2018 3:36 PM, "Doğan Kurt" wrote: I think i wasn't perfectly clear. When i say update i actually meant insert, delete, update. I will delete big blocks of elements, insert new ones and modify some. If i have to deal with the json format, what's the point of

Re: [go-nuts] Question about the spec: Method Sets and Pointer Receivers

2018-02-05 Thread Burak Serdar
On Mon, Feb 5, 2018 at 10:42 AM, theckman via golang-nuts wrote: > Hey Gophers, > > I've run in to an interesting case regarding Method Sets that makes me > wonder whether it should be disallowed by the spec[1]. Before opening an > issue on GitHub I thought I'd reach

Re: [go-nuts] Syntax problem, please help me

2018-02-15 Thread Burak Serdar
On Thu, Feb 15, 2018 at 8:41 AM, junije wen wrote: > I'm reading the source code of Iris and trying to reimplement it. > There is a line I can't understand. > > if p, is := e.Engine.(EngineRawExecutor); is { >return p.ExecuteRaw(src, wr, binding) > } > > The define of

Re: [go-nuts] json encoding & decoding interface types

2018-02-19 Thread Burak Serdar
On Mon, Feb 19, 2018 at 4:45 PM, Doğan Kurt wrote: > Hi great Go community. Sorry it's a long question, but i would really > appreciate some guidance. > > > > > > Let's say i have two different objects, browser and executable that > implement

Re: [go-nuts] json -> struct -> html template

2018-02-20 Thread Burak Serdar
On Tue, Feb 20, 2018 at 5:23 PM, Alex Dvoretskiy wrote: > Hello golang-nuts, > > https://play.golang.org/p/Lib9EfWcsjG > > If you run this code it works fine. But if you remove one "Actor" key - > template stops executing: "template: movielist:10:14: executing "movielist"

Re: [go-nuts] json encoding & decoding interface types

2018-02-20 Thread Burak Serdar
func unmarshal(...) { ... for _,d:=range detects { if x, ok:=dict[d.Type]; ok { u:=x() json.Unmarshal( d.Object,) // append u to slice } } > > On Tuesday, February 20, 2018 at 1:03:51 AM UTC+1, Burak Serdar wrote: >> >> On M

Re: [go-nuts] Loosing type after json.Unmarshal

2018-02-20 Thread Burak Serdar
On Tue, Feb 20, 2018 at 9:25 AM, wrote: > Hi, > > please have a look at this code why do I loose type information after > json.Unmarshal? structA is an interface{}. Before unmarshal, it is pointing to a StructA value. Unmarshal, seeing that the argument is an

Re: [go-nuts] Reference to type satisfying a specified interface

2018-08-30 Thread Burak Serdar
Did you try something like this? What errors did you get? type Event interface { ... } type EventImpl struct { ... } eventSlice:=make([]Event,0) eventMap:=make(map[string]Event) event:={} eventSlice=append(eventSlice,event) eventMap["key"]=event On Thu, Aug 30, 2018 at 10:57 AM Eric

Re: [go-nuts] Reference to type satisfying a specified interface

2018-08-30 Thread Burak Serdar
On Thu, Aug 30, 2018 at 11:34 AM Eric Raymond wrote: > > > > On Thursday, August 30, 2018 at 1:14:25 PM UTC-4, Jan Mercl wrote: >> >> On Thu, Aug 30, 2018, 18:57 Eric Raymond wrote: >>> >>> I'm trying to translate this to Go in a type-safe way. To do this, I need >>> to be able to write two

Re: [go-nuts] Reference to type satisfying a specified interface

2018-08-30 Thread Burak Serdar
On Thu, Aug 30, 2018 at 12:09 PM Eric Raymond wrote: > > >> >> If Event is your interface and EventImpl is your struct, what you need >> is a map[string]Event, not map[string]*Event. Make sure you put >> {} to your slices and maps, not EventImpl{} >> > > Here'a what is confusing me. Yes, I can

Re: [go-nuts] Reference to type satisfying a specified interface

2018-08-30 Thread Burak Serdar
On Thu, Aug 30, 2018 at 12:49 PM Eric Raymond wrote: > > > > On Thursday, August 30, 2018 at 2:18:38 PM UTC-4, Burak Serdar wrote: >> >> If b is an interface to a *Blob, what's stored in the slice is {Type: >> *Blob, Value: pointer to the object}. A copy of t

[go-nuts] Maybe vet can detect this?

2018-09-06 Thread Burak Serdar
https://play.golang.org/p/KLXvFNCewyW Here, f2() never returns nil, because the returned "nil" valued interface is of type *int. It would be really nice if vet could warn if a function returns an interface, and there exist a code path in that function where the return value is set from a

Re: [go-nuts] Re: Maybe vet can detect this?

2018-09-06 Thread Burak Serdar
warn against this use. > > 6 Eylül 2018 Perşembe 22:15:17 UTC+3 tarihinde Burak Serdar yazdı: >> >> https://play.golang.org/p/KLXvFNCewyW >> >> Here, f2() never returns nil, because the returned "nil" valued >> interface is of type *int. >> &g

Re: [go-nuts] Pass by value in struct not yielding expected result

2018-03-06 Thread Burak Serdar
On Tue, Mar 6, 2018 at 1:23 PM, wrote: > go version 1.10 > > > Operating system and processor architecture > > GOHOSTARCH="amd64" > GOHOSTOS="darwin" > However, this happens in play.golang.org env as well. > > > Checkout the code. > >

Re: [go-nuts] Pass by value in struct not yielding expected result

2018-03-06 Thread Burak Serdar
if the structure will be used as read-only and has a reasonable size, a copy of it is just fine. In my opinion, the only general rule is that you have to know how the data is organized and that you know what you're doing. > > On Tuesday, March 6, 2018 at 3:40:47 PM UTC-5, Burak Serdar wrote: >

Re: [go-nuts] confusing a lock demo about https://golang.org/ref/mem#tmp_8

2018-03-13 Thread Burak Serdar
The second lock waits until f() runs and unlocks the mutex. On Tue, Mar 13, 2018 at 3:37 AM, 郎凯 wrote: > var l sync.Mutex > var a string > > func f() { > a = "hello, world" > l.Unlock() > } > > func main() { > l.Lock() > go f() > l.Lock() > print(a) > } > > I'm a new

Re: [go-nuts] Goroutines, Nonblocking I/O, And Memory Usage

2018-03-15 Thread Burak Serdar
What about something like: type TimedReader interface { TimedRead(out []byte,timeout int) (int,error) } so r.TimedRead(buf,0) becomes a non-blocking read? On Thu, Mar 15, 2018 at 11:23 AM, Michael Jones wrote: > What about: "wait, then get a buffer from a pool, and

Re: [go-nuts] tcp net.Conn deadlocks when message size increased

2018-03-09 Thread Burak Serdar
Read stops reading if it needs to block. https://play.golang.org/p/TwtGzzBEnXV On Fri, Mar 9, 2018 at 8:44 AM, wrote: > Hi all > > I've written a simple program which simply sends a message across a tcp > connection and back again. > > For some reason when I make the

Re: [go-nuts] fixed random number trouble

2018-03-14 Thread Burak Serdar
It is explained here: https://golang.org/pkg/math/rand/ On Wed, Mar 14, 2018 at 11:26 AM, Andrea Alessandrini wrote: > I wrote this simple code > > package main > import ( > "fmt" > "math/rand" > ) > func main() { > for i := 0; i < 6; i++ { > fmt.Println("My

Re: [go-nuts] Sorting slice of structs

2018-04-10 Thread Burak Serdar
Simple mistake. You have: sort.Slice(arr, func(i, j int) bool { return arr[i].X < arr[i].X }) Instead use: sort.Slice(arr, func(i, j int) bool { return arr[i].X < arr[j].X }) On Tue, Apr 10, 2018 at 12:28 PM, Sankar wrote: > Hi > > I have the following code: > >

Re: [go-nuts] int int32 int64

2018-03-16 Thread Burak Serdar
On Fri, Mar 16, 2018 at 12:11 PM, Alex Dvoretskiy wrote: > Hello Golangnuts, > > I'm experiencing unexpected behavior. Trying to reverse integer. > > This code works on 64-bit machine, but working wrong on 32-bit: > > https://play.golang.org/p/p4Ptu8cx-b7 on 32-bit

Re: [go-nuts] Long running task in select case

2018-03-16 Thread Burak Serdar
On Fri, Mar 16, 2018 at 8:45 AM, Sathish VJ wrote: > All the examples I've seen use some kind of ticker to run various cases of a > select statement. But how does one run a long running task that is still > cancelable? > > > In the example below the quit part is never

Re: [go-nuts] Re: Cannot take the adress of.....

2018-02-27 Thread Burak Serdar
On Mon, Feb 26, 2018 at 10:01 PM, wrote: > or similar simpler example : > > this works : > > var j int = 42 > var p *int > p= // this works > fmt.Println(*p) > > > > var j int = 42 > var p *int > p=(j) //this doesn't

Re: [go-nuts] Golang short variable declaration needs at least one must not be declared?

2018-10-11 Thread Burak Serdar
The IDE is probably buggy, but you are wrong as well. The problem is c.file, not err. c.file cannot be on the left side of :=, it is not a name you can redeclare. You have to write: var err error c.file, err= os.OpenFile... or: f, err:=os.OpenFile c.file=f On Thu, Oct 11, 2018 at 7:21 PM

Re: [go-nuts] Golang short variable declaration needs at least one must not be declared?

2018-10-11 Thread Burak Serdar
my bad English > > On Friday, October 12, 2018 at 9:32:28 AM UTC+8, Burak Serdar wrote: >> >> The IDE is probably buggy, but you are wrong as well. The problem is >> c.file, not err. >> >> c.file cannot be on the left side of :=, it is not a name you can >

Re: [go-nuts] Does client.go#transport() reuse s global DefaultTransport when http.Client's Transport is nil?

2018-10-17 Thread Burak Serdar
On Wed, Oct 17, 2018 at 10:30 AM Kyle Butz wrote: > > Hi All! > > I'm having trouble understanding whether a new http.Client{} with no > Transport set will use a new copy of DefaultTransport, or the global? > > From client.go: > > func (c *Client) transport() RoundTripper { >if c.Transport

Re: [go-nuts] Does client.go#transport() reuse s global DefaultTransport when http.Client's Transport is nil?

2018-10-17 Thread Burak Serdar
ew client, I am using the > same Transport? That appears to be the case. > > On Wednesday, October 17, 2018 at 11:35:52 AM UTC-5, Burak Serdar wrote: >> >> On Wed, Oct 17, 2018 at 10:30 AM Kyle Butz wrote: >> > >> > Hi All! >> > >> > I'm having

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
ny errors. > > you would need to create: > > struct MyNode { > Link *Node > value int > } > > and make link exported - meaning you need to understand the internal details > of LinkedList in order to use it. > > At least I think

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 11:35 AM Ian Lance Taylor wrote: > > On Wed, Oct 17, 2018 at 11:58 AM, Burak Serdar wrote: > > > > Instead of specifying the minimal set of operations a type should > > satisfy, why not describe what the type should look like: > > > > f

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
A function with an interface template in its signature becomes a template: func F(in I) Need to work on some real examples to see how this develops... > > > On Oct 18, 2018, at 8:09 AM, Burak Serdar wrote: > > > >> On Thu, Oct 18, 2018 at 6:35 AM Robert Engels > &g

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 8:53 AM Robert Engels wrote: > > > > > On Oct 18, 2018, at 9:41 AM, Burak Serdar wrote: > > > > If X is a struct type, any type implementing all the methods of X and > >containing all the fields of X can be substituted > >

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 8:53 AM Robert Engels wrote: > > > > > On Oct 18, 2018, at 9:41 AM, Burak Serdar wrote: > > > > If X is a struct type, any type implementing all the methods of X and > >containing all the fields of X can be substituted > >

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
ing won't work: > > package A > > struct MyNode {private fields} > > package B > > l.Add({}) > > However, if private fields of MyNode is accessible where Add() is > instantiated, Add should compile without any errors. > > > > > > > > you would nee

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
{ next *TheNode more stuff } var myLinkedList TheLinkedList myLinkedList.Add() works now. I do not like the "type name templatename" syntax, something else is needed there. > > > On Oct 18, 2018, at 11:08 AM, Burak Serdar wrote: > > > > On Thu, O

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 1:22 PM robert engels wrote: > > Can you explain this a bit more, I must be missing something. Using the > example: > > func F(a,b type T like(int,X)) { > if a ... > } > } > > How do you pass a struct to F because < isn’t valid on structs ??? You missed the part

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 2:02 PM Ian Denhardt wrote: > > Quoting robert engels (2018-10-18 15:22:36) > > Can you explain this a bit more, I must be missing something. Using the > > example: > > > > func F(a,b type T like(int,X)) { > > if a > ... > > } > > } > > > > How do you pass a

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 12:28 PM Ian Denhardt wrote: > > Quoting Andy Balholm (2018-10-18 14:00:52) > > > That would also be a weakness of most of the other proposals, > > including my own to add operators to interfaces. Contracts are more > > powerful, at the expense of extra complexity. > >

Re: [go-nuts] Question about fmt.Printf of maps

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 10:37 PM Rusco wrote: > > I just tried this Google Playground recipe from Bradfritz: > > https://play.golang.org/p/RYac90kI-H > > (seen via https://github.com/golang/go/issues/21095) > > and noted that y appears in the output but x appears as . > > Can someone explain me

Re: [go-nuts] Re: A suggestion for the error handling proposal

2018-10-22 Thread Burak Serdar
completely and call the handler when error variable is assigned a non-nil value. On Mon, Oct 22, 2018 at 9:14 AM Jon Conradt wrote: > > I got a 404 when I tried to access this. Perhaps it is not public? > > Jon > > On Monday, October 22, 2018 at 10:33:38 AM UTC-4, Burak Serdar

[go-nuts] A suggestion for the error handling proposal

2018-10-22 Thread Burak Serdar
I read the error handling proposal recently, and although I like it in general, I don't like the fact that it hides the actual error variables from the flow. Also, I think the error chaining method as described in the proposal is not very useful. So I came up with this suggestion:

Re: [go-nuts] Regarding contracts

2018-10-22 Thread Burak Serdar
On Mon, Oct 22, 2018 at 1:53 PM Marvin Renich wrote: > > * Burak Serdar [181018 15:08]: > > tbh, I am not trying to avoid operator overloading, I am trying to > > avoid the contracts. With operator overloading, you can write: > > > >

Re: [go-nuts] Re: A suggestion for the error handling proposal

2018-10-22 Thread Burak Serdar
s to be the closest topic. > > Feel free to add your gist link to the wiki! > > On Monday, October 22, 2018 at 7:33:38 AM UTC-7, Burak Serdar wrote: >> >> I read the error handling proposal recently, and although I like it in >> general, I don't like the fact that it hides the

Re: [go-nuts] Regarding contracts

2018-10-19 Thread Burak Serdar
On Fri, Oct 19, 2018 at 10:38 AM Eric S. Raymond wrote: > > Ian Denhardt : > > I feel like Burak's proposal is falling into the same trap as many others: > > there is a common feeling that operator overloading is a Pandora's box, so > > folks are trying to work around it by solving the problem

Re: [go-nuts] Regarding contracts

2018-10-19 Thread Burak Serdar
On Fri, Oct 19, 2018 at 12:01 PM Ian Denhardt wrote: > > Quoting Burak Serdar (2018-10-19 12:34:44) > > Re: Ian Denhardt's proposal: > > > > I agree that it handles all the cases in the official proposal, > > but I think the syntax is too verbose and remind

Re: [go-nuts] Regarding contracts

2018-10-19 Thread Burak Serdar
On Fri, Oct 19, 2018 at 7:13 AM Robert Engels wrote: > > I don’t think it matters, since when writing the generic code using methods > the author has strict control over the precedence. > > Also, for equality testing, the signature would be bool Equals(interface{}) > with required casting.

Re: [go-nuts] Regarding contracts

2018-10-19 Thread Burak Serdar
On Fri, Oct 19, 2018 at 12:36 PM Ian Lance Taylor wrote: > > On Thu, Oct 18, 2018 at 10:48 AM, Burak Serdar wrote: > > On Thu, Oct 18, 2018 at 11:35 AM Ian Lance Taylor wrote: > >> > >> On Wed, Oct 17, 2018 at 11:58 AM, Burak Serdar wrote: > >> > &g

Re: [go-nuts] Regarding contracts

2018-10-20 Thread Burak Serdar
On Sat, Oct 20, 2018 at 9:42 AM Ian Denhardt wrote: > > Quoting Burak Serdar (2018-10-19 17:01:42) > > On Fri, Oct 19, 2018 at 1:09 PM Ian Denhardt wrote: > > > > > > Quoting Burak Serdar (2018-10-19 14:09:46) > > > > > > > It is useful

Re: [go-nuts] Regarding contracts

2018-10-19 Thread Burak Serdar
On Fri, Oct 19, 2018 at 11:48 AM Eric S. Raymond wrote: > > Burak Serdar : > > Where can I read about this "implements"? Link? > > https://groups.google.com/forum/#!topic/golang-nuts/pR5pmql5olM > > After subsequent discussion I would only add these points

Re: [go-nuts] Regarding contracts

2018-10-19 Thread Burak Serdar
On Fri, Oct 19, 2018 at 1:26 PM Eric S. Raymond wrote: > > Burak Serdar : > > So the question is: do we really need to declare exactly what the > > implementation of a generic needs in the contract, or is it sufficient > > to say "use this with values that

Re: [go-nuts] Regarding contracts

2018-10-19 Thread Burak Serdar
On Fri, Oct 19, 2018 at 1:09 PM Ian Denhardt wrote: > > Quoting Burak Serdar (2018-10-19 14:09:46) > > > It is useful in a linked list. You can instantiate a linked list > > template in a package, and use that concrete type in another package > > without access to the i

Re: [go-nuts] NaN as map key?

2018-10-21 Thread Burak Serdar
r type in reflect (https://tip.golang.org/pkg/reflect/#MapIter), > the behaviour you see now will change. Thanks, that makes sense. > > On Sun, 2018-10-21 at 16:33 -0600, Burak Serdar wrote: > > Someone asked a question a few days ago related to this, and it's > > been > >

[go-nuts] NaN as map key?

2018-10-21 Thread Burak Serdar
Someone asked a question a few days ago related to this, and it's been bugging me since then. Is this an undefined behavior according to the spec? https://play.golang.org/p/RqgD492EZ9U The code results in a map with two NaN keys, both of which have nil values. I think having two NaN keys is

[go-nuts] Regarding contracts

2018-10-17 Thread Burak Serdar
Disclaimer: I don't work on languages. I just don't like the idea of writing contracts. Instead of specifying the minimal set of operations a type should satisfy, why not describe what the type should look like: func f(in like T) This means 'in' should be a type that has all the operations

Re: [go-nuts] Regarding contracts

2018-10-17 Thread Burak Serdar
On Wed, Oct 17, 2018 at 1:47 PM Andy Balholm wrote: > > That’s a very interesting idea. It would probably need to be extended to > allow specifying that a type is like multiple types. Then the effective > “contract” would be the intersection of the operations provided by those > types. For

Re: [go-nuts] Regarding contracts

2018-10-18 Thread Burak Serdar
On Thu, Oct 18, 2018 at 6:35 AM Robert Engels wrote: > > I meant to say contract not interface. Also as a user of said generic routine > how do I know all of the available method on a type I would need to implement > as I don’t know which ones the method may be using... > > Interfaces solve the

Re: [go-nuts] Re: Command line password manager using AES symmetric key encryption, Argon2 KDF, Key-Agent and Keepass importer

2018-10-18 Thread Burak Serdar
On Tue, Oct 16, 2018 at 1:55 PM Matthias Schmidt wrote: > > And here it is: > > https://github.com/ms140569/loki/releases/tag/1.2.0 Thanks for sharing this. I find this interesting because I've been working on a very similar idea for an OIDC token manager CLI, and came up with almost the same

Re: [go-nuts] Go 2 Proposal Comments

2018-10-24 Thread Burak Serdar
On Wed, Oct 24, 2018 at 9:59 AM robert engels wrote: > > To this day, you can take a “binary” written for Java 1.0 and it will run > under the latest JRE. You can compile Java 1.0 source code with the latest > compiler. This is an amazing accomplishment that can’t be understated. That is not

Re: [go-nuts] Regarding contracts

2018-10-24 Thread Burak Serdar
} meaning StrNum must be an integer that implements String() The "type switch" for contracts imply that contracts are a runtime construct. In my case, contracts are purely compile time. > > Andy > > On Oct 23, 2018, at 9:37 AM, Burak Serdar wrote: > > On Mon, Oct 22, 2018

Re: [go-nuts] Go 2 Proposal Comments

2018-10-24 Thread Burak Serdar
s in Java is a convoluted piece of mess. > > On Oct 24, 2018, at 11:12 AM, Burak Serdar wrote: > > On Wed, Oct 24, 2018 at 9:59 AM robert engels wrote: > > > To this day, you can take a “binary” written for Java 1.0 and it will run > under the latest JRE. You can c

Re: [go-nuts] Regarding contracts

2018-10-23 Thread Burak Serdar
On Mon, Oct 22, 2018 at 2:10 PM Burak Serdar wrote: > > On Mon, Oct 22, 2018 at 1:53 PM Marvin Renich wrote: > > > > * Burak Serdar [181018 15:08]: > > > tbh, I am not trying to avoid operator overloading, I am trying to > > > avoid the contracts. With

Re: [go-nuts] Using default in select causes a deadlock

2018-10-24 Thread Burak Serdar
ch starts waiting on c - main waits on quit > > On Wednesday, 24 October 2018 22:44:26 UTC+5:30, Burak Serdar wrote: >> >> You can do this instead: >> >> https://play.golang.org/p/avMIyYlwxbF >> On Wed, Oct 24, 2018 at 11:05 AM Sathish VJ wrote: >> &g

Re: [go-nuts] Using default in select causes a deadlock

2018-10-24 Thread Burak Serdar
You can do this instead: https://play.golang.org/p/avMIyYlwxbF On Wed, Oct 24, 2018 at 11:05 AM Sathish VJ wrote: > > This is a program where the receiver is asking the sender to close after > receiving 1 value. Using default for the sending (line 34) causes the code > to deadlock while even

Re: [go-nuts] Regarding contracts

2018-10-24 Thread Burak Serdar
(int) would probably produce exactly the same machine code as That's a neat idea. > > func MinInt(a, b int) int { > if a < b { > return a > } > return b > } > > Andy > > > On Oct 24, 2018, at 9:47 AM, Burak Serdar wrote: >

Re: [go-nuts] Re: Generics: an unwelcome conclusion and a proposal

2018-10-28 Thread Burak Serdar
On Sun, Oct 28, 2018 at 7:00 AM Scott Cotton wrote: > > > > On Thursday, 18 October 2018 08:00:56 UTC+2, Beoran wrote: >> >> After reading his proposal, I think you should help Burak Sedar work out his >> proposal in the other thread. > > > Where is Burak Sedar's proposal?

Re: [go-nuts] Invoke "go test" to execute exactly two specific tests?

2018-10-29 Thread Burak Serdar
On Mon, Oct 29, 2018 at 3:09 PM Craig Rodrigues wrote: > > Hi, > > I have a suite of 20 tests, each test corresponding to a function: func > Test(). > > Out of the 20 tests, I have two specific tests: > > func TestXG() > func TestNiceSystem() > > I want to invoke go test -test.run to

Re: [go-nuts] Go 2 Error Handler Testing

2018-10-30 Thread Burak Serdar
On Tue, Oct 30, 2018 at 2:15 PM Liam wrote: > > I've compiled an outline of Requirements to Consider for Go 2 Error Handling. > > Recently I was asked about support for a test harness in functions that > contain error handlers; my document doesn't address this. My first guess is > that the

Re: [go-nuts] Regarding contracts

2018-10-25 Thread Burak Serdar
On Thu, Oct 25, 2018 at 10:32 AM Andy Balholm wrote: > > > > On Oct 25, 2018, at 6:45 AM, Marvin Renich wrote: > > The most powerful feature of the contracts described in the original > design draft is the ability to describe interactions between two types > in a type specification. Your

Re: [go-nuts] Failed iterator proposals?

2018-10-25 Thread Burak Serdar
On Thu, Oct 25, 2018 at 1:53 PM Eric S. Raymond wrote: > > robert engels : > > Wouldn’t you normally pass a consumer or collector function into the > > interator code? Then you only write the iterator once, and it is hidden. > > I'll look into that approach. There might be a readability issue

Re: [go-nuts] Re: Go 2 Proposal Comments

2018-10-26 Thread Burak Serdar
On Fri, Oct 26, 2018 at 9:32 PM robert engels wrote: > > OK, you got me, I’m sucked in - it was a nice balance of yes, BUT no. > > First, there is simply no debate, Java += Android, and you have the most > successful language/platform ever. NO debate. > > Arguing against Java’s write-once, run

Re: [go-nuts] Go 2 Proposal Comments

2018-10-27 Thread Burak Serdar
On Sat, Oct 27, 2018 at 2:53 AM Wojciech S. Czarnecki wrote: > > On Wed, 24 Oct 2018 10:59:12 -0500 > robert engels wrote: > > > If you head back to the genesis time of Java, > > Can you get all this Java babble out of the **GO** focused list, please! > > In less PC times it was called by its

Re: [go-nuts] Code generated by generics draft

2018-11-03 Thread Burak Serdar
On Sat, Nov 3, 2018 at 2:12 PM Wojciech S. Czarnecki wrote: > > > Future: I'll consider Burak Sedar's **like Type** within CGG contract. fyi: I got some useful feedback on this, especially from Scott Cotton, and I am working on some sort of formal framework (using go 1) where I can test if this

Re: [go-nuts] Re: Go2 Error Handling Feedback

2018-11-01 Thread Burak Serdar
On Thu, Nov 1, 2018 at 5:18 AM Laurent Moussault wrote: > > IMHO, this kind of refactorization actually makes the code less readable, for > everyone but the programmer that just wrote it. Though it may seem obvious at > first what functions like "CopyFile" do, an outsider reading the code will

Re: [go-nuts] Draft error handling design - could 'check' and 'handle' be 'contextual' keywords?

2018-10-27 Thread Burak Serdar
On Sat, Oct 27, 2018 at 5:53 PM alanfo wrote: > > As a general principle, Ian, that makes sense to me and perhaps it's > something we could all unite on. > > The remaining problem is how to distinguish between the two cases - new > keywords used as such or as ordinary identifiers. > > Your

Re: [go-nuts] Draft error handling design - could 'check' and 'handle' be 'contextual' keywords?

2018-10-27 Thread Burak Serdar
On Sat, Oct 27, 2018 at 11:26 AM roger peppe wrote: > > > > On Sat, 27 Oct 2018, 5:46 pm > >> So you're basically saying that an identifier should either be reserved or >> not and that there should be no contextual keywords at all, not even >> contract. > > > Yes, I agree with this. FWIW the

Re: [go-nuts] front-end post a body, back-end use gin.Context BindJSON but fail

2018-11-09 Thread Burak Serdar
On Fri, Nov 9, 2018 at 6:35 AM wrote: > > front-end info > //body struct > type Bucket struct { >Name string `json:"name"` >KeyId string `json:"key_id"` >KeySecret string `json:"key_secret"` >Header*Header `json:"header"` >Property int `json:"property"` >

Re: [go-nuts] json: cannot unmarshal array into Go struct field data.Members of type main.Members

2018-10-09 Thread Burak Serdar
Members.slug is not exported. It should be Members.Slug, not Members.slug On Tue, Oct 9, 2018 at 6:45 AM wrote: > > > type Members struct { > slug string `json:"slug"` > } > type data struct { > Members Members //`json:"members"` > } > > func main() { > > resp, err := >

Re: [go-nuts] Re: string question

2018-10-02 Thread Burak Serdar
https://blog.golang.org/constants Foo is an untyped constant. Bar is a string. On Tue, Oct 2, 2018 at 1:11 PM Greg Saylor wrote: > > Also it would appear that foo("hello") succeeds to. > > - Greg > > > On Tuesday, October 2, 2018 at 12:05:04 PM UTC-7, Greg Saylor wrote: >> >> Hello, >> >> I'm

Re: [go-nuts] Casting Back from nested Struct

2018-10-10 Thread Burak Serdar
On Wed, Oct 10, 2018 at 10:04 AM Chris Hopkins wrote: > > Hi, > I appreciate this is not possible, but realised I never understood why (so > have just been working around it). > Example code at: > https://play.golang.org/p/BgFL9T0KiC7 > > I can create a struct with other structs as a member. I

Re: [go-nuts] What is nil pointer dereference?

2019-01-20 Thread Burak Serdar
On Sun, Jan 20, 2019 at 2:32 PM 伊藤和也 wrote: > > type a interface{ >m() > } > > type abc int > func (abc) m() {} > > func main() { >var v a >v.m() ^^ v is nil. It is declared but never assigned a value. You are dereferencing v to call m, causing nil ptr dereference. > } > >

Re: [go-nuts] Forking/transfering a repository and import paths

2018-12-12 Thread Burak Serdar
On Wed, Dec 12, 2018 at 9:08 AM Robert Engels wrote: > > Yes, but you still need to maintain both repos or things will break. > > I am pretty sure that the correct solution is to decouple the package from > its location. And a global Go registry can tell Go get where that package can >

Re: [go-nuts] Go offline development recommendations

2018-12-12 Thread Burak Serdar
On Wed, Dec 12, 2018 at 1:00 PM snmed wrote: > > Hi all > > Our customer demands an offline development environment with no internet > connection, is there any best practices to handle package download and > project setup for such an use case? And how would the new go modules fit in > in such

Re: [go-nuts] Channels: selecting the last element

2018-12-18 Thread Burak Serdar
On Tue, Dec 18, 2018 at 6:35 AM Chris Burkert wrote: > > Dear all, > > I have a couple of goroutines sending multiple results over a channel - a > simple fan-in. They signal the completion on a done channel. Main selects on > the results and done channel in parallel. As the select is random

Re: [go-nuts] Channels: selecting the last element

2018-12-18 Thread Burak Serdar
On Tue, Dec 18, 2018 at 9:01 AM Skip Tavakkolian wrote: > > why not just drop the select? i think the following is guaranteed because > putting things on rc has to succeed before putting true into dc: That will serialize all goroutines. They'll run one after the other. > > package main > >

Re: [go-nuts] A Numeric Type for Go?

2018-12-14 Thread Burak Serdar
On Fri, Dec 14, 2018 at 11:00 AM wrote: > > When programmers complain about the lack of generics in Go, a common > mitigation proposed is to use a interface. In many cases, it's possible to > find an operation common to all the types to be supported; in the worst case, > an empty interface can

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

2018-11-30 Thread Burak Serdar
On Fri, Nov 30, 2018 at 11:09 AM Jakob Borg wrote: > > 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. ...or any potential

Re: [go-nuts] recursion plus goroutines

2018-11-30 Thread Burak Serdar
On Fri, Nov 30, 2018 at 12:44 PM Alex Dvoretskiy wrote: > > Hi, > > How should I modify my code if I want to run three recursive functions in > parallel? > > go inOrderTr(root) > go preOrderTr(root) > go postOrderTr(root) Those three are mutually independent, and the tree is read-only, so you

Re: [go-nuts] Strange behaviour of left shift

2018-12-05 Thread Burak Serdar
On Wed, Dec 5, 2018 at 9:55 AM Michel Levieux wrote: > > Well the only thing I do in the main is : > >> fmt.Println(v) > > > Shouldn't the compiler statically type v to uint64? > I don't get the need to force type of v to uint64? v is an untyped constant. When passed to Println, it is an int.

Re: [go-nuts] concurent pipe

2018-12-04 Thread Burak Serdar
On Tue, Dec 4, 2018 at 11:57 AM Alex Dvoretskiy wrote: > > Hi Golangnuts, > > I'm trying to implement kind of pipe function, using channels > > Do you think this would be a correct conception: > > func Pipe(fs ...task) { > > ch1 := make(chan interface{}) > ch2 := make(chan interface{}) > > for _,

Re: [go-nuts] golang.org/x/oauth2 bug???

2018-12-07 Thread Burak Serdar
On Fri, Dec 7, 2018 at 6:46 AM Harald Fuchs wrote: > > I think there's something fishy about clientcredentials. Having > trouble with client_secrets containig special chars, first I modified > clientcredentials_test.go like this: > > > func TestTokenRequest(t *testing.T) { > > cfg := newConf("")

  1   2   3   4   5   >