Re: [go-nuts] Why were method sets designed like this?

2025-06-10 Thread burak serdar
On Tue, Jun 10, 2025 at 2:06 PM Alexander Shopov wrote: > > Does anyone have any idea why method sets were designed like this? > > Method sets of pointer types include the methods defined on the type > that the pointer points to (Explicitly pointed out in spec > https://go.dev/ref/spec#Method_sets

Re: [go-nuts] Surprised by inflexibility of time.Parse wrt 1 or 2 digit months

2025-06-09 Thread burak serdar
You are right. I thought this worked. On Mon, Jun 9, 2025, 10:16 PM David Karr wrote: > I did. It fails to parse dates with two digits for the month or day. > > On Monday, June 9, 2025 at 12:05:26 PM UTC-7 burak serdar wrote: > >> >> >> On Mon, Jun 9, 20

Re: [go-nuts] Surprised by inflexibility of time.Parse wrt 1 or 2 digit months

2025-06-09 Thread burak serdar
On Mon, Jun 9, 2025, 10:00 PM David Karr wrote: > I've used "time.Parse()" several times in various small applications, and > today I realized a curious inflexibility with it. If I have to parse date > values where the months or days could be either 1 or 2 digits, which is all > cases if the cod

Re: [go-nuts] The motivation for the use of length in copy function instead of the capacity

2025-05-28 Thread burak serdar
On Wed, May 28, 2025 at 10:41 AM Сергей Пилипенко wrote: > > Hello, gophers! > > I have attempted to use the copy function for slices and found it’s API a bit > strange. Suppose I have two slices: one of size 0 and capacity 10, the other > of size 10 and capacity 10. When I copy the second one i

Re: [go-nuts] Why can't single-method interfaces not be implemented by embedding?

2025-02-27 Thread burak serdar
The embedded name `EqualName` shahows the method called `EqualName`. Rename the `EqualName` interface to `EqualNamer`, and things work. On Thu, Feb 27, 2025 at 10:07 AM cpu...@gmail.com wrote: > > About every single time I feel like I understand Go interfaces I'm being > taught differently. >

Re: [go-nuts] reset sync.OnceValue

2024-11-25 Thread burak serdar
s once. So https://pkg.go.dev/sync/atomic#Value seems to > be a better fit, do you agree? > > burak serdar schrieb am Freitag, 22. November 2024 um 16:10:00 UTC+1: >> >> On Fri, Nov 22, 2024 at 1:53 AM 'Hartmut Wieselburger' via golang-nuts >> wrote: >> > >

Re: [go-nuts] reset sync.OnceValue

2024-11-22 Thread burak serdar
of Once another goroutine will see. A goroutine may see the completed instance of Once even after you Reset() it. > > func Load() *Config { > configOnce.Do(func() { > ... > } > > burak serdar schrieb am Donnerstag, 21. November 2024 um 21:24:40 UTC+1: >> >> On Thu, Nov

Re: [go-nuts] reset sync.OnceValue

2024-11-21 Thread burak serdar
On Thu, Nov 21, 2024 at 1:14 PM 'Hartmut Wieselburger' via golang-nuts wrote: > > Hi, > is there a way to reset sync.OnceValue(s), as you can do it with sync.Once? How can you reset a sync.Once? > A common use case is loading a config. I would like to switch from sync.Once > to sync.OnceValue,

Re: [go-nuts] Re: Using structs, pointers, and maps

2024-10-07 Thread burak serdar
Mixing pointer and value receivers can be race-prone, because of the copying involved in passing value receivers. On Mon, Oct 7, 2024 at 12:03 PM 'Axel Wagner' via golang-nuts wrote: > > To be honest, I always found this recommendation a little bit strange, > personally. > > I'll note that the s

Re: [go-nuts] How to define struct with defined properties that is also a map

2024-09-12 Thread burak serdar
The current json implementation in the stdlib does not support a catchall like that. Also, you cannot embed a map in a struct. You can replace JIRAFields with a map[string]any. If there are keys with known structures, you can do a map[string]json.RawMessage, and then you can do json.Unmarshal(fiel

Re: [go-nuts] Advice on Using Pure Go with eBPF

2024-08-13 Thread burak serdar
As far as I know, you cannot write ebpf code using Go. You can write C code for ebpf filters, and then use Go to install it and interface with it. Take a look at Cilium tools. You might also want to take a look at https://github.com/kubeshark/tracer. On Tue, Aug 13, 2024 at 4:55 PM Sharon Mafgaoke

Re: [go-nuts] Does data race with only multiple goroutine parallel i=1 have an impact on the execution results?

2024-07-06 Thread burak serdar
The way I read the section about programs with memory races (https://go.dev/ref/mem#restrictions), that program should always print 1. "A read r of a memory location x holding a value that is not larger than a machine word must observe some write w such that r does not happen before w and there is

Re: [go-nuts] Re: just started using modules, what have i missed?.

2024-05-02 Thread burak serdar
You can simply clone the github repo. You don't need go get for this. When you're ready, import it and then go mod tidy. On Thu, May 2, 2024 at 3:39 PM 'simon place' via golang-nuts wrote: > > thanks for the reply, yes a library, that i want to investigate, i don't have > a project until after.

Re: [go-nuts] Where is my type?

2024-04-24 Thread burak serdar
In the first case, the interface contains a value of type S, which is not writable. The value contained in the interface is not addressable. So Unmarshal creates a new map and fills that. In the second case the interface contains *S, which is writable, so unmarshal fills it in via reflection. On W

Re: [go-nuts] Re: xml to json, parsing xml

2024-04-23 Thread burak serdar
In general, you cannot convert xml to json. They have incompatible models. XML elements are ordered similar to a JSON array, but in many cases you want to map XML elements to JSON objects, which are unordered name-value collections. Also, there is no JSON equivalent of an XML attribute. If you wan

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread burak serdar
On Wed, Mar 13, 2024 at 10:31 AM Rodrigo Araujo wrote: > > Do you mean b.GetChilder? In this case, package A will depend on package B > and I don't think this is a good approach. Why would it not be a good approach? You have a package declaring interfaces, and if you have another package using t

Re: [go-nuts] How to have a raw parameter value in cobra?

2024-02-25 Thread burak serdar
but nothing else. > > On Sunday, February 25, 2024 at 10:52:10 AM UTC-8 burak serdar wrote: >> >> You can do rootCmd.SetArgs(os.Args[2:]), and process the first >> parameter yourself. >> >> On Sun, Feb 25, 2024 at 11:43 AM David Karr wrote: >> > >>

Re: [go-nuts] How to have a raw parameter value in cobra?

2024-02-25 Thread burak serdar
You can do rootCmd.SetArgs(os.Args[2:]), and process the first parameter yourself. On Sun, Feb 25, 2024 at 11:43 AM David Karr wrote: > > I am not a new programmer, but I am pretty new to golang, having only written > a couple of small applications, and that was several months ago. I'm trying >

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-22 Thread burak serdar
On Thu, Feb 22, 2024 at 10:39 AM Axel Wagner wrote: > > > > On Thu, Feb 22, 2024 at 6:06 PM burak serdar wrote: >> >> I don't think this case really applies here. I get that comparison of >> a==b may or may not be true. The problem is that if a==b at some poin

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-22 Thread burak serdar
gt;> >> I see. Sorry, I was jumping to conclusions and didn't quite get what you >> mean. That is my fault. >> >> I agree that this looks confusing and is arguably a bug. I filed >> https://github.com/golang/go/issues/65878, thanks for pointing it out. >>

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-22 Thread burak serdar
always. But apart from > that, who knows. > > Zero-sized variables *may* have the same address. They don't *have* to. > > On Thu, Feb 22, 2024 at 5:12 PM burak serdar wrote: >> >> On Thu, Feb 22, 2024 at 9:00 AM Axel Wagner >> wrote: >> > &

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-22 Thread burak serdar
ne is true and the other is not. > > On Thu, Feb 22, 2024 at 4:53 PM burak serdar wrote: >> >> The compiler can allocate the same address for empty structs, so I >> actually expected a==b to be true, not false. However, there's >> something more interestin

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-22 Thread burak serdar
The compiler can allocate the same address for empty structs, so I actually expected a==b to be true, not false. However, there's something more interesting going on here because: a := &Foo{} b := &Foo{} fmt.Printf("%t\n", *a == *b) fmt.Printf("%t\n", a == b) fmt.Printf("%p %p\n", a, b) x := Bar(a

Re: [go-nuts] Is there a way to cast interface to embedded type?

2024-02-09 Thread burak serdar
On Fri, Feb 9, 2024 at 1:37 PM Christopher C wrote: > > I have a base struct that implements an interface. There are multiple other > structs that embed this base struct. I would like to pass the an interface > into a function that can cast it as the base struct and call some functions > tied

Re: [go-nuts] Incorrect "missing return" error for an edge case

2024-01-08 Thread burak serdar
ot in > > the loop body - in particular, if you want to do it on a purely > > syntactical level). > > It also also can be replaced by `func TestMethod() int { return 0 }`, > > which is strictly better, more readable code, so I wouldn't even > > necessarily agre

[go-nuts] Incorrect "missing return" error for an edge case

2024-01-07 Thread burak serdar
This question came up on Stack Overflow today: The following code is giving a "missing return" error where it shouldn't: func TestMethod() int { for i := 0; i < 10; i++ { return 0 } } Looks like an overlooked case in control flow analysis. -- You received this message because you

Re: [go-nuts] Go type assertion for MongoDB []bson.M{}/primitive.A type

2023-11-16 Thread burak serdar
"].(primitive.A)[0] > var a1 author > bson.Unmarshal(r.([]byte), &a1) > a = append(a, a1) > > I'm getting: > > panic: interface conversion: interface {} is primitive.M, not []uint8 > > > On Thursday, November 16, 2023 at 12:20:13 PM UTC-5 burak serdar wrote: &g

Re: [go-nuts] Go type assertion for MongoDB []bson.M{}/primitive.A type

2023-11-16 Thread burak serdar
val["author"].(primitive.A)[0] is correct, but the type of that expression is not author, it is bson.M. You might consider using a tagged struct to unmarshal this. On Thu, Nov 16, 2023 at 10:11 AM Tong Sun wrote: > > Further on with the question > https://stackoverflow.com/questions/60072372/fil

Re: [go-nuts] Re: Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-14 Thread burak serdar
inlining the version function, but according to the spec, it is passed by value, i.e., it is copied. On Tue, Nov 14, 2023 at 4:16 PM burak serdar wrote: > > It is a data race because calling rpc.version() makes a copy of rpc, > which causes reading the field rpc.result concurrently wh

Re: [go-nuts] Re: Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-14 Thread burak serdar
It is a data race because calling rpc.version() makes a copy of rpc, which causes reading the field rpc.result concurrently while it is being written by the goroutine. On Tue, Nov 14, 2023 at 3:59 PM Mike Schinkel wrote: > > On Monday, November 13, 2023 at 11:28:00 PM UTC-5 Dan Kortschak wrote: >

Re: [go-nuts] When to share an interface, and when not to.

2023-09-26 Thread burak serdar
On Tue, Sep 26, 2023 at 6:18 AM Jerry Londergaard wrote: > > > Do I need to be re-defining this interface everywhere? I guess > an alternative would be to just re-use the `C.DoThinger`, but I feel like > this doesn't seem right as now A is directly importing C, which seems to > 'break' the abstr

Re: [go-nuts] Ensure context timeout behaviour from caller, or callee ?

2023-09-20 Thread burak serdar
hat if we are running things in goroutines, and > passing down the context, > and the code being run in those goroutines isn't listening for cancellation > signals, > which results in the running goroutine becoming leaked, then that feels like > a bug in that code (i.e

Re: [go-nuts] Ensure context timeout behaviour from caller, or callee ?

2023-09-20 Thread burak serdar
On Wed, Sep 20, 2023 at 7:47 AM Jerry Londergaard wrote: > > When using a context.WithTimeout, I always felt that it should be the > function where the context was created should be the one that ensures that it > (the current function) does not block longer than intended. That is to say, > it s

Re: [go-nuts] Download large Zip file via sftp

2023-08-23 Thread burak serdar
On Wed, Aug 23, 2023 at 6:37 AM Phillip Siessl wrote: > Hi > > i have some issues when i try to download a larger zip file (5GB) via the > sftp package in go. > about 20% of the time it runs through smoothly but the other 80% i get a > panic with > "fatal error: concurrent map writes writing to f

Re: [go-nuts] Is atomic.CompareAndSwap a read-aquire (even if it returns false)?

2023-08-20 Thread burak serdar
Based on the following description in the memory model, CAS counts as a read: "Some memory operations are read-like, including read, atomic read, mutex lock, and channel receive. Other memory operations are write-like, including write, atomic write, mutex unlock, channel send, and channel close. S

Re: [go-nuts] Best IDE for GO ?

2023-08-20 Thread burak serdar
On Sun, Aug 20, 2023 at 1:52 AM TheDiveO wrote: > well, our "(major) engineering orgs" leave the choice of IDE to our devs. > Devs have different styles, so as long as they meed the demand, who cares. > I second that. IDE is a personal choice. For years, I've been using Emacs to edit code, and t

Re: [go-nuts] Clarification on code snippet

2023-08-04 Thread burak serdar
On Fri, Aug 4, 2023 at 10:33 AM alchemist vk wrote: > Hi folks, > In below code, I am invoking receiver api show() via a simple uInteger > type variable instead of pointer, by which it expects to be invoked . Go > being strict with type casing and I was expecting a compiler error. But to > my s

Re: [go-nuts] Hard-to-explain race detector report

2023-06-08 Thread burak serdar
On Wed, Jun 7, 2023 at 2:19 PM Sven Anderson wrote: > > > Caleb Spare schrieb am Mi. 7. Juni 2023 um 19:22: > >> On Wed, Jun 7, 2023 at 2:33 AM Sven Anderson wrote: >> > >> > That’s not only a read/write race, it’s also a write/write race. Every >> request to the server creates a new Go routine

Re: [go-nuts] Hard-to-explain race detector report

2023-06-07 Thread burak serdar
On Wed, Jun 7, 2023, 12:33 PM Sven Anderson wrote: > That’s not only a read/write race, it’s also a write/write race. Every > request to the server creates a new Go routine that might increment > newConns in parallel, so it may get corrupted. Same for lines 39/40. > The write/write race will hap

Re: [go-nuts] Hard-to-explain race detector report

2023-06-07 Thread burak serdar
On Tue, Jun 6, 2023 at 5:31 PM Caleb Spare wrote: > Can someone explain why the following test shows a race between the > indicated lines? > > > https://github.com/cespare/misc/blob/b2e201dfbe36504c88e521e02bc5d8fbb04a4532/httprace/httprace_test.go#L12-L43 > > The race seems to be triggered by t

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-06-03 Thread burak serdar
On Sat, Jun 3, 2023 at 1:40 PM peterGo wrote: > > Kamil Ziemian, > > // list of prime numbers > primes := []int{2, 3, 5, 7, 9, 2147483647} > > The variable prime is a list of some prime numbers starting with the > lowest and ending with the highest prime numbers that can safely be > represented a

Re: [go-nuts] Using struct{} for context keys

2023-05-28 Thread burak serdar
Two values A and B are equal (A==B) if A and B have the same type and the same values. In a code where a:=clientContextKey{} b:=clientContextKey{} a==b is true, because they have the same types, and they have the same values (i.e. the empty value). Note however: a:=&clientContextKey{} b:=&cl

Re: [go-nuts] Experience with building JS and Python bindings for a Go library

2023-05-22 Thread burak serdar
On Mon, May 22, 2023 at 6:35 PM Taco de Wolff wrote: > I would like to know if anyone has experience with building bindings for > JavaScript (NodeJS) and Python for a Go library. Who has worked on this, or > does anybody know of libraries that have succeeded? > I used the following two libraries

Re: [go-nuts] Immediately Cancel Goroutine?

2023-04-12 Thread burak serdar
On Wed, Apr 12, 2023 at 7:29 AM Frank wrote: > Hi Gophers, > > So I've run into a situation where my code would run for a rather long > time (10minutes - ~1 hour). And I want to cancel it halfway sometimes. I > know I can use channel/context can check for channel message to return > early. But th

Re: [go-nuts] Map of Types is impossible, is there any alternative solution?

2023-04-11 Thread burak serdar
You can do: var messageProcessors = map[uint8]func([]byte) Message { 0: processorForType0, 1: processorForType1, ... } Then: output:=messageProcessors[id](payload) Of course, with the appropriate error checks. On Tue, Apr 11, 2023 at 3:13 PM Bèrto ëd Sèra wrote: > I do know there's no

Re: [go-nuts] Interesting "select" examples

2023-04-03 Thread burak serdar
Below is part of a generic ordered fan-in for data pipelines. It works by reading data from multiple channels using one goroutine for each channel, sending that data element to another goroutine that does the actual ordering, but in the mean time, pauses the pipeline stage until all out-of-order da

Re: [go-nuts] HTTP client - streaming POST body?

2023-03-22 Thread burak serdar
On Wed, Mar 22, 2023 at 8:32 PM 'Christian Stewart' via golang-nuts < golang-nuts@googlegroups.com> wrote: > you can achieve this using an io.Pipe. The io.Pipe function returns a > connected pair of *PipeReader and *PipeWriter, where writes to the > *PipeWriter are directly read from the *PipeRead

Re: [go-nuts] Why can't a regexp.Regexp be const

2023-02-13 Thread burak serdar
This compiles just fine, but the regexp compilation fails: https://go.dev/play/p/QvC8CIITUU6 On Mon, Feb 13, 2023 at 4:49 PM Pat Farrell wrote: > This won't compile > > var ExtRegex = > regexp.MustCompile("(M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$") > > with a > ./prog.go:10:18: > regexp.MustCom

Re: [go-nuts] Upgradable RLock

2023-01-29 Thread burak serdar
On Sun, Jan 29, 2023 at 7:34 PM Diego Augusto Molina < diegoaugustomol...@gmail.com> wrote: > From times to times I write a scraper or some other tool that would > authenticate to a service and then use the auth result to do stuff > concurrently. But when auth expires, I need to synchronize all my

Re: [go-nuts] Clarification of memory model behavior within a single goroutine

2023-01-21 Thread burak serdar
On Sat, Jan 21, 2023 at 12:11 PM Peter Rabbitson (ribasushi) < ribasu...@gmail.com> wrote: > On Saturday, January 21, 2023 at 7:48:12 PM UTC+1 bse...@computer.org > wrote: > On Sat, Jan 21, 2023 at 10:36 AM Peter Rabbitson > wrote: > Greetings, > > I am trying to understand the exact mechanics of

Re: [go-nuts] Clarification of memory model behavior within a single goroutine

2023-01-21 Thread burak serdar
On Sat, Jan 21, 2023 at 10:36 AM Peter Rabbitson wrote: > Greetings, > > I am trying to understand the exact mechanics of memory write ordering > from within the same goroutine. I wrote a self-contained runnable example > with the question inlined here: https://go.dev/play/p/ZXMg_Qq3ygF and am >

Re: [go-nuts] Simple Regexp fails but more complex one finds match

2023-01-19 Thread burak serdar
This: (-)* matches the empty string as well, and that's what it is returning. Try (-)+ On Thu, Jan 19, 2023 at 12:16 PM Pat Farrell wrote: > This has to be something simple, but I've been pulling my hair out for > days. > I have made two regexp.MustCompile where one is just a simple punctuatio

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread burak serdar
On Wed, Jan 18, 2023 at 5:52 PM Andrew Athan wrote: > (Possibly related to issues such as those discussed in > https://groups.google.com/g/golang-nuts/c/pO2sclKEoQs/m/5JYjveKgCQAJ ?) > > If I do: > > ``` > func Foo[V any](v V)bool { > return v==v > } > ``` > > golang 1.19 reports: > > ``` > inv

Re: [go-nuts] Re: Why not tuples?

2022-12-03 Thread burak serdar
On Sat, Dec 3, 2022 at 8:47 PM Diogo Baeder wrote: > Hi there, sorry for weighting in so late in the game, but I just started > again to learn Go and was thinking why the language still doesn't have a > tuple type. > > Now, imagine this scenario: I have a web application which has to access a > w

Re: [go-nuts] Performance for concurrent requests

2022-12-02 Thread burak serdar
On Fri, Dec 2, 2022 at 8:13 PM Diogo Baeder wrote: > Hi guys, > > I've been working on some experiments with different web application > stacks to check their performances under a specific scenario: one in which > I have to make several concurrent requests and then gather the results > together (

Re: [go-nuts] Go Memory Model question

2022-12-02 Thread burak serdar
The way I read the memory model, this program can print 01, 00, and 11, but not 10. This is because goroutine creation creates a synchronized before relationship between x=1 and x=0, so even though there is a race, x=0 happens before x=1. On Fri, Dec 2, 2022 at 6:56 AM のびしー wrote: > > I believe

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-12-01 Thread burak serdar
On Thu, Dec 1, 2022 at 6:39 AM 'Mark' via golang-nuts < golang-nuts@googlegroups.com> wrote: > The reason there's no nullable in the real code is that it isn't needed > there: if the field is to a pointer variable (e.g., *string), then I call > hack() and that adds the '?' to the string so no need

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-11-30 Thread burak serdar
On Wed, Nov 30, 2022 at 10:17 AM 'Mark' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Yes, I'd already tried that (that's what I started with) and unfortunately > it doesn't work. > It fails if field.Elem() is nil. Try this: kind = field.Type().Elem().Kind() > > On Wednesday, Nove

Re: [go-nuts] How to fix an awful marshal reflection hack

2022-11-30 Thread burak serdar
On Wed, Nov 30, 2022 at 5:29 AM 'Mark' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I have this code which works but has a horrible hack: > ... > nullable := false > kind := field.Kind() // field's type is reflect.Value > if kind == reflect.Ptr { > This should work: kind = field.Elem

Re: [go-nuts] Understanding some gotchas with linking slices together via indexing

2022-11-01 Thread burak serdar
On Tue, Nov 1, 2022 at 10:49 PM Brian, son of Bob wrote: > Can anyone explain these gotchas (demo )? > I've tried reading articles on this [one > , two >

Re: [go-nuts] Atomic pointers to arrays and sequenced-before guarantees for array elements

2022-10-30 Thread burak serdar
Based on my reading of the Go memory model, this algorithm sketch is memory-race free. However, there is a race condition. Here's the reason: The writer issues a synchronized-write to array pointer, and another synchronized-write to the array len. A reader issues a synchronized read. the correspo

Re: [go-nuts] Detecting JSON changes

2022-10-10 Thread burak serdar
On Mon, Oct 10, 2022 at 8:50 AM Slawomir Pryczek wrote: > Hi Guys, > I have 2 json files, A, B. Now i want to detect changes on the root level. > > File A: {"a":{"b":1, "c":2}, "x":false, ... } > File B: {"a":{"b":1, "c":2}, "x":true, ... } > > I want to be able to see that x is different betwe

Re: [go-nuts] Structures / mutex question

2022-10-09 Thread burak serdar
On Sun, Oct 9, 2022 at 12:44 PM Slawomir Pryczek wrote: > Thanks, very good point about including the structure by-value. > > As for using the structure via pointer > > > You don't need to rlock the global mutex. Even if another goroutine > appends to > > the slice and slice gets reallocated, thi

Re: [go-nuts] Structures / mutex question

2022-10-09 Thread burak serdar
On Sun, Oct 9, 2022 at 5:49 AM Slawomir Pryczek wrote: > Hi Guys, > wanted to see if i making correct assumptions regarding mutexes and > structures > > var globalMutex sync.Mutex{} > type abc struct { > a int > b int > mu sync.Mutex{} > } > > 1. First is self explanatory, array of st

Re: [go-nuts] Shared Goruntime across different microservices written in GO

2022-09-28 Thread burak serdar
On Wed, Sep 28, 2022 at 11:02 PM Roland Müller wrote: > Microservices are located in containers and making these services to use a > common binary would break the basic idea of microservices. > Not necessarily. A single binary containing multiple services gives the flexibility to be run as a mon

Re: [go-nuts] understanding interface conversions

2022-09-22 Thread burak serdar
s, I believe, something Go got right. > > On Sep 22, 2022, at 7:58 PM, burak serdar wrote: > >  > > > On Thu, Sep 22, 2022 at 6:30 PM Robert Engels > wrote: > >> I would like to understand the reason to type assert but not cast? That >> is an OO design

Re: [go-nuts] understanding interface conversions

2022-09-22 Thread burak serdar
ific type, or if the value underlying the interface also implements a different set of methods. And Go isn't OO. > > On Sep 22, 2022, at 7:24 PM, burak serdar wrote: > >  > > > On Thu, Sep 22, 2022 at 6:08 PM Robert Engels > wrote: > >> 100% true. The dif

Re: [go-nuts] understanding interface conversions

2022-09-22 Thread burak serdar
On Thu, Sep 22, 2022 at 6:08 PM Robert Engels wrote: > 100% true. The difficulty when examining a “large” system is that it > becomes very difficult to understand the relationships. Documentation can > help but it is not a great substitute for automated tools. > > In Java - actually all of OO - t

Re: [go-nuts] understanding interface conversions

2022-09-22 Thread burak serdar
On Thu, Sep 22, 2022 at 4:27 PM Rory Campbell-Lange wrote: > This email follows my email yesterday "cannot convert fs.FS zip file to > io.ReadSeeker (missing Seek)". Thanks very much to those who replied and > provided solutions. > > Following that, I'm interested to learn how people negotiate in

Re: [go-nuts] Re: Error-checking with errors.As() is brittle with regards to plain vs pointer types

2022-09-22 Thread burak serdar
That is not always true. I saw code that looks like this a few days ago: what the author was trying to do was to handle a specific type of error differently, and pass it along if the error is some other type: type CustomError struct{} func (e CustomError) Error() string { return "error" } func g

[go-nuts] Labeled property graphs and embedded openCypher library

2022-09-20 Thread burak serdar
I would like to announce two open-source Go libraries we have been working on: Labeled Property Graphs: https://github.com/cloudprivacylabs/lpg This library supports openCypher (Neo4j) style of labeled property graphs in memory. That is: * Nodes have a set of labels, and a set of key-values,

Re: [go-nuts] Race detector question

2022-09-15 Thread burak serdar
On Thu, Sep 15, 2022 at 9:21 AM Thomas Bushnell BSG wrote: > On Thu, Sep 15, 2022 at 11:19 AM burak serdar > wrote: > >> On Thu, Sep 15, 2022 at 9:11 AM Thomas Bushnell BSG >> wrote: >> >>> I cannot speak to "other accepted concurrency designs" h

Re: [go-nuts] Race detector question

2022-09-15 Thread burak serdar
On Thu, Sep 15, 2022 at 9:19 AM Thomas Bushnell BSG wrote: > On Thu, Sep 15, 2022 at 11:16 AM robert engels > wrote: > >> This is simply incorrect. The ‘issue’ about clarifying the memory has >> been about “happens before” since the beginning. The model was clarified. >> The race detector cannot

Re: [go-nuts] Race detector question

2022-09-15 Thread burak serdar
t;> } >>> w.Done() >>>}() >>>w.Wait() >>> >>> } >>> >>> The above code does not have a race, or Go doesn’t have “happens before” >>> semantics with its atomics. >>> >>> >>> On Sep 15

Re: [go-nuts] Race detector question

2022-09-15 Thread burak serdar
On Thu, Sep 15, 2022 at 8:03 AM 'Thomas Bushnell BSG' via golang-nuts < golang-nuts@googlegroups.com> wrote: > You cannot make that assumption. It's not about what the race detector can > detect. > > Goroutine one: > Writes non-synchronized X > Writes atomic Y > Writes non-synchronized Z wit

Re: [go-nuts] Assigning struct values

2022-09-07 Thread burak serdar
On Wed, Sep 7, 2022 at 12:28 PM Mustafa Durukan wrote: > > > *fakeObject := tt.Object.(TypeOfStruct)object := Object.(TypeOfStruct)* If you can include the definitions of tt, explain what you want to do, and what you mean by "didn't work", someone may be able to answer this question. Without t

Re: [go-nuts] Struct with Interfaces fields as key in maps

2022-08-31 Thread burak serdar
On Wed, Aug 31, 2022 at 7:28 AM antonio.o...@gmail.com < antonio.ojea.gar...@gmail.com> wrote: > Hi, > > Based on the documentation: > > "The map key can be any type that is comparable." > "Struct values are comparable if all their fields are comparable. Two > struct values are equal if their corr

Re: [go-nuts] Pipelining with Go and Generics

2022-08-11 Thread burak serdar
On Thu, Aug 11, 2022 at 2:37 PM Robert Engels wrote: > I don’t think that is relevant. It is very difficult to do chaining with > Go’s error model. You can pass a shared context to every node and store the > error in the context and protect against concurrent access. It’s doable but > not easy. >

Re: [go-nuts] Preemptive interfaces in Go

2022-08-09 Thread burak serdar
On Tue, Aug 9, 2022 at 1:52 PM Tim Peoples wrote: > Yeah, I'm with Burak on this one. The interface usage you're describing > Henry is exactly the kind of thing I'm talking about. While on the surface > it may seem advantageous -- in fact, I also tried writing Go that way when > I first started

Re: [go-nuts] Preemptive interfaces in Go

2022-08-09 Thread burak serdar
On Mon, Aug 8, 2022 at 11:27 PM Henry wrote: > I am sure that many of us have been on that journey. After using Go for > some time, we discover some practices that are not necessarily in agreement > with the existing "adages" but effectively solve our problems. > > For me, if the data type is mut

Re: [go-nuts] Preemptive interfaces in Go

2022-08-08 Thread burak serdar
On Mon, Aug 8, 2022 at 12:51 PM Tim Peoples wrote: > I don't necessarily consider the "multiple implementations" case as being > truly preemptive -- if there really are multiple implementations (e.g. the > "hash" package from the standard library). > > I'm much more concerned about interfaces tha

Re: [go-nuts] Preemptive interfaces in Go

2022-08-08 Thread burak serdar
On Mon, Aug 8, 2022 at 11:17 AM Tim Peoples wrote: > > For years I've read the old adage, "Accept interfaces, return structs" and > have spent years working to instill this understanding among my colleagues. > I gathered a great many skills while learning Go (and acquiring > readability) back in

Re: [go-nuts] A pedantic question about updating a map during iteration

2022-08-02 Thread burak serdar
None of the conditions specified in that clause applies for updating key in-place. The way I read it, a new entry is not added, so the iteration should visit every entry only once. Thus, the program always prints "1 1". On Tue, Aug 2, 2022 at 9:20 PM Kevin Chowski wrote: > Hello Go gurus, > > I

Re: [go-nuts] concurrent read/write different keys in map

2022-08-02 Thread burak serdar
What exactly do you mean by "read/write 5 different keys"? If you have a map[int]*SomeStruct, for instance, and if you initialize this map with some entries, and then if you have multiple goroutines all performing lookups of distinct keys and modifying the contents of *SomeStruct, it would be safe

Re: [go-nuts] Re: testing examples printing to stdout not working for global var

2022-05-02 Thread burak serdar
On Mon, May 2, 2022 at 2:57 PM 'simon place' via golang-nuts < golang-nuts@googlegroups.com> wrote: > i see, thanks > > the implementation of 'go test' (which the playground runs > auto-magically.) replaces os.Stdout with a new reference behind the scenes > before running the func, but after makin

Re: [go-nuts] Re: testing examples printing to stdout not working for global var

2022-05-02 Thread burak serdar
On Mon, May 2, 2022 at 9:00 AM psi@gmail.com wrote: > #1 the two functions need to behave identically according to the syntax of > the language. > > #2 this is how working code operates, so testing needs to be able to > handle it. > > at a guess; 'testing' would appear to have some non-compli

Re: [go-nuts] Question regarding Golang Interfaces and composite struct

2022-04-28 Thread burak serdar
On Thu, Apr 28, 2022 at 9:49 AM Glen D souza wrote: > Consider the following piece of code > > type Dog struct { > } > > type Walker interface { > Walks() > } > > func (d *Dog) Walks() { > > } > > func CheckWalker(w Walker) { > > } > > func main() { > dog := Dog{} > CheckWalker(dog) -

Re: [go-nuts] Hesitating on using cached / un-cached channels

2022-04-11 Thread burak serdar
An unbuffered channel is a synchronization mechanism. A send on an unbuffered channel will block until there is a concurrent receive from another goroutine. Your program has only one goroutine. A send to an unbuffered channel will always deadlock, so will a receive from it. So the problem you are

Re: [go-nuts] RFC: function or interface?

2022-03-31 Thread burak serdar
On Thu, Mar 31, 2022 at 1:14 PM Adam Pritchard wrote: > I’m working on a library to help get the “real” client IP from HTTP > requests: > https://github.com/realclientip/realclientip-go > https://pkg.go.dev/github.com/realclientip/realclientip-go > > Right now the “strategies” are like: > > type

Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread burak serdar
u can allow > many more unique words by extending the interned string type to 8 > bytes. > > On Jan 9, 2022, at 3:07 PM, burak serdar wrote: > >  > Note that a with a map[string]string, the code: > > m[s]=s > > The contents of the string s are not duplicated, only the st

Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread burak serdar
On Sun, Jan 9, 2022 at 4:30 PM jlfo...@berkeley.edu wrote: > > > On Sunday, January 9, 2022 at 3:07:18 PM UTC-8 bse...@computer.org wrote: > >> Note that a with a map[string]string, the code: >> >> m[s]=s >> >> The contents of the string s are not duplicated, only the string header s >> is. >> >

Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread burak serdar
Note that a with a map[string]string, the code: m[s]=s The contents of the string s are not duplicated, only the string header s is. On Sun, Jan 9, 2022 at 3:52 PM jlfo...@berkeley.edu wrote: > I'm aware of Artem Krylysov's idea for string interning published on > https://artem.krylysov.com/bl

Re: [go-nuts] Amateur question: when you should use runes?

2021-11-15 Thread burak serdar
On Mon, Nov 15, 2021 at 11:00 AM Kamil Ziemian wrote: > Hello, > > I read quite a few blog posts, articles, listen to nice number to talks > about strings, runes and encoding in Go. I now reading Go Language Spec and > I just stuck in the section about runes. I mean, it isn't hard as itself, > bu

Re: [go-nuts] Why Doesn't "len()" Work With Structs?

2021-10-25 Thread &#x27;burak serdar' via golang-nuts
On Sun, Oct 24, 2021 at 12:12 PM jlfo...@berkeley.edu < jlforr...@berkeley.edu> wrote: > I noticed that the len() function doesn't take a struct as an argument > (see below). > This is a big surprise. Can someone shed some light on why this > restriction exists? > len() gives the number of elemen

Re: [go-nuts] Re: Why Doesn't "len()" Work With Structs?

2021-10-25 Thread &#x27;burak serdar' via golang-nuts
On Sun, Oct 24, 2021 at 6:54 PM jlfo...@berkeley.edu wrote: > I'm now aware that that I could use > > len(([unsafe.Sizeof(T{})][0]byte{})) > > But this seems overly complicated. Plus, I don't see why > this is unsafe. Please advise. > Sizeof is unsafe because it returns the number of bytes of th

Re: [go-nuts] Loading Certificate and Key from string not file for HTTPs server

2021-09-13 Thread burak serdar
On Mon, Sep 13, 2021 at 3:03 PM Sam Caldwell wrote: > Does anyone have any ideas of an easy path to load certificate and key > files from a string rather than a file? > > *Use Case:* > 1. traditionally we all put a cleartext file on disk with our private key > and public certificate. If the serv

Re: [go-nuts] Right way to fan out work loads

2021-09-08 Thread burak serdar
On Wed, Sep 8, 2021 at 10:02 AM David Belle-Isle wrote: > > Hi, > > I've been facing this question for a while and never managed to find the > "right" answer. Hopefully this forum will be able to enlighten me a little > bit. > > Given a very simple pattern: Consume some data, transform it, store

Re: [go-nuts] HTTP request matching different endpoint - gorilla mux

2021-09-02 Thread burak serdar
Your paths are ambiguous. "/nfdm-fdm/v2/shared-data" matches "/nfdm-fdm/v2/{id}" where id=shared_data. You can use a regex for the path with {id} to exclude the "shared_data" match. On Thu, Sep 2, 2021 at 10:13 AM Van Fury wrote: > Hi All, > > I have the following to handler functions, DataSets

[go-nuts] gofmt error formatting suggestion

2021-08-10 Thread burak serdar
Here is an idea to make reading code a bit easier: If gofmt can format this: f, err:=os.Open(file) if err!=nil { return err } as: f, err:=os.Open(file); if err!=nil { return err } it would make reading code easier by pushing the error passing code to the right. This formatting would only be

Re: [go-nuts] The behavior of the function variable which points to the struct method

2021-08-10 Thread burak serdar
On Tue, Aug 10, 2021 at 3:50 PM E Z wrote: > It works when I changed the code as your suggested. That's great, thanks. > > And I'm still a little confused here, you know when we use the struct > method directly, it is only when the function is called that the type of > receiver determines whether

  1   2   3   4   5   >