Re: [go-nuts] Short Variable Declarations Are Oversold

2023-04-23 Thread Jesper Louis Andersen
On Sun, Apr 23, 2023 at 12:31 AM jlfo...@berkeley.edu < jlforr...@berkeley.edu> wrote: > > Short definitions detract from one of Go’s primary goals - readability. I > started using Go in the first place because I wanted a strongly typed > language with explicit type declarations. > > Your claim of

Re: [go-nuts] Immediately Cancel Goroutine?

2023-04-12 Thread Jesper Louis Andersen
It depends. If you know everything you have done is safely on disk somewhere, or you have a stateless system, you can end the application by a panic. However, in the event your program or requirements change, it can be desirable to mix in lifecycle management early on. This includes graceful shut

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

2023-04-04 Thread Jesper Louis Andersen
On Tue, Apr 4, 2023 at 2:22 AM Nigel Tao wrote: > > I'd have to study mux9p for longer, but its select chooses between two > receives, so it could possibly collapse to a single heterogenous > channel. Indeed, both its channels are already heterogenous in some > sense. Both its processTx and proce

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-15 Thread Jesper Louis Andersen
On Tue, Mar 14, 2023 at 10:25 AM Van Fury wrote: > Am developing a server (diameter) which will response with an AVP > SIP-Authenticate. > In the specification > > " The SIP-Authenticate AVP is of type OctetString and It shall contain, > binary encoded, the concatenation of the authentication ch

Re: [go-nuts] Is Go a security malware risk?

2022-08-25 Thread Jesper Louis Andersen
On Thu, Aug 25, 2022 at 7:54 AM Amnon wrote: > Apparently Go is an "unconventional language". So Languages are divided > into "conventional" and "unconventional" > languages. Any language split like this often fails to capture the essence of different language designs. We should use precision i

Re: [go-nuts] Is Go a security malware risk?

2022-08-23 Thread Jesper Louis Andersen
On Tue, Aug 23, 2022 at 2:58 PM 'Gopher-Insane' via golang-nuts < golang-nuts@googlegroups.com> wrote: > They are suggesting that Go is being more widely used than others, making > it more of a risk. > > Is their position "we shouldn't write Go in our organization, because it's being used by malwa

Re: [go-nuts] Is Go a security malware risk?

2022-08-23 Thread Jesper Louis Andersen
On Mon, Aug 22, 2022 at 3:30 PM 'Gopher-Insane' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Hi > > So our security team has raised a concern with Go and malware. The link > that was sent to me was > https://securityboulevard.com/2021/09/behavior-based-detection-can-stop-exotic-malware

Re: [go-nuts] Functions vs Methods: explain reasoning behind STD

2022-06-02 Thread Jesper Louis Andersen
On Thu, Jun 2, 2022 at 4:38 PM Deividas Petraitis wrote: > Background: when I am writing code mostly I end up with some clunky > solutions I am not happy with and one of the reasons I think is that I > might be mixing funcs vs methods. > > Squint your eyes enough, and methods are just a special k

Re: [go-nuts] Why Go has only slice and map

2022-04-12 Thread Jesper Louis Andersen
Very true! On Tue, Apr 12, 2022 at 8:36 PM Robert Engels wrote: > Nit but you can certainly create maps and slices in a library - you use > methods not language syntax - as long as you have pointers and type > casting. > > On Apr 12, 2022, at 1:30 PM, Jesper

Re: [go-nuts] Why Go has only slice and map

2022-04-12 Thread Jesper Louis Andersen
On Tue, Apr 12, 2022 at 8:19 AM 'Jack Li' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Hi group, > > Why Go provides only 2 built-in data structures, slice and map. It has > just more than C, but less than all other programming languages I've heard > of, C++, Python, Swift, Rust. > > I

Re: [go-nuts] Why does infinitely-recursing code not give stack overflow in Playground?

2022-04-11 Thread Jesper Louis Andersen
On Wed, Apr 6, 2022 at 3:18 AM ben...@gmail.com wrote: > Normally the Go Playground gives errors when a runtime panic or other > error occurs, including "timeout running program" for programs that run too > long. I'm wondering why the Playground doesn't show a stack overflow error > (or any error

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

2022-01-26 Thread Jesper Louis Andersen
On Sun, Jan 9, 2022 at 11:52 PM jlfo...@berkeley.edu wrote: > > I'm wondering if there's a map-like data structure that would store a > string > as the key, and the address of the key as the value. I'm aware that a > standard > Go map can't be used for this because its components might be moved a

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread Jesper Louis Andersen
On Fri, Sep 17, 2021 at 11:09 AM rmfr wrote: > One of our Golang applications has a very huge binary size and the size of > the .text segment itself in the elf is approximately *34MB*. The iTLB > load miss reaches about *87%* of all iTLB cache hits. > > Is there any advice for big Golang applicat

Re: [go-nuts] Re: slices grow at 25% after 1024 but why 1024?

2021-09-05 Thread Jesper Louis Andersen
On Sun, Sep 5, 2021 at 3:59 PM jake...@gmail.com wrote: > Like Brian, I think part of he problem is possibly a miscommunication > based on "monotonically increasing". The term means that each point is > greater than, *or equal to*, the previous one. > https://en.wikipedia.org/wiki/Monotonic_funct

Re: [go-nuts] Re: How to implement this in golang?

2021-06-29 Thread Jesper Louis Andersen
On Tue, Jun 29, 2021 at 5:24 PM LetGo wrote: > Thanks for the answer! (: > In python it was straightforward to implement and it works like a charm. > It sends small packets with delay between each other without even care if > it is UDP or TCP: > > Beware! This is an assumption that will break at

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-23 Thread Jesper Louis Andersen
On Wed, Jun 23, 2021 at 12:55 PM a2800276 wrote: > More practically though, most programmers would probably prefer to follow >> guidance provided by the authors of the library they are using because by >> virtue of having written the library, the authors probably understand not >> only the librar

Re: [go-nuts] How is golang web applications for seo

2021-06-01 Thread Jesper Louis Andersen
On Tue, Jun 1, 2021 at 6:39 PM Scott Beeker wrote: > How are golang web applications on a scale of 1 to 10 for seo rankings? > > This scale is on a different dimension than that of the choice of Go! Go doesn't impose any restrictions on your efforts of playing nice with a search engine. But it r

Re: [go-nuts] Is the escape analysis reports accurate?

2021-05-23 Thread Jesper Louis Andersen
On Sun, May 23, 2021 at 10:51 AM tapi...@gmail.com wrote: > In the following code, "make([]T, n)" is reported as escaped. > But does it really always escape at run time? > Does the report just mean "make([]T, n) possibly escapes to heap"? > > The safe bet in the system is to mark every possible (

Re: [go-nuts] Guarantee tcp pkt delivery

2021-05-19 Thread Jesper Louis Andersen
On Wed, May 19, 2021 at 1:37 PM Amarjeet Anand wrote: > Consider a sequence of events--- > > 1. Tcp server started on port 8080 using *net.Listen("tcp", ":8080")* > > 2. Tcp client established a connection using *net.Dial("tcp", ":8080") *and > received a *conn* object. > > 3. Tcp server is force

Re: [go-nuts] Still "missing" priority or ordered select in go?

2021-05-06 Thread Jesper Louis Andersen
On Wed, May 5, 2021 at 11:34 PM Bakul Shah wrote: > > Imagine that the latency between the device detecting a disconnect > signal and a user hitting a disconnect button is D ns while the fire > detection latency is F ns. So if D > F the device would raise the > alarm even if you implement it all

Re: [go-nuts] How string constants are propagated inside a small func

2021-05-04 Thread Jesper Louis Andersen
On Sat, May 1, 2021 at 1:28 PM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > > func g() string { > s1 := "a" > s2 = s1 + "b" > return s > } > > Errata: it should have been `return s2` rather than `

Re: [go-nuts] Where is defined what recursive type declarations are allowed?

2021-05-04 Thread Jesper Louis Andersen
On Tue, May 4, 2021 at 8:03 AM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Thanks :) At least I didn't overlook anything :) > fwiw, I also searched the spec and found nothing. I found that peculiar. Recursive types require special treatment in type theory, so it is like

Re: [go-nuts] Recursive type definition

2021-05-04 Thread Jesper Louis Andersen
On Tue, May 4, 2021 at 1:16 AM Delta Echo wrote: > > Not sure what "handle" means in this case. > > I want to know how this is implemented. > > At some point in the compiler, you have type erasure, and you have an untyped language. From there on, it's a function pointer / label. And you allow for

Re: [go-nuts] Recursive type definition

2021-05-03 Thread Jesper Louis Andersen
On Mon, May 3, 2021 at 6:43 PM Delta Echo wrote: > > Hi, Is there any document that explains how recursive type definitions > like > > type stateFn func(*Scanner) stateFn > > are handled in Go? > > Is this a type-level question (roughly boiling down to if the type is equi- or iso-recursive) or is

Re: [go-nuts] Recommendations of Go front-ends for single page SaaS application

2021-05-01 Thread Jesper Louis Andersen
On Wed, Apr 28, 2021 at 12:28 AM Joseph Jones wrote: > Hi Everyone, > > I am trying to decide what front-end to use with a Go backend. It seems > natural to use a Go frontend framework as well but I have not found a lot > of them. > > A couple of haphazard thoughts: The most important one is tha

Re: [go-nuts] How string constants are propagated inside a small func

2021-05-01 Thread Jesper Louis Andersen
On Fri, Apr 30, 2021 at 7:51 PM 'Valentin Deleplace' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I don't know exactly what SSA does in the compiler, but I thought it would > be capable of optimizing f and g into the exact same generated code. Am I > missing something? > Roughly, SSA

Re: [go-nuts] rationale for math.Max(1, math.NaN()) => math.NaN()?

2021-04-22 Thread Jesper Louis Andersen
On Thu, Apr 22, 2021 at 11:54 AM 'Dan Kortschak' via golang-nuts < golang-nuts@googlegroups.com> wrote: > > Does anyone know the reason for this? (Looking through other languages, > the situation in general seems to be a mess). > > I looked at OCaml, which provides both variants: Float.max : floa

Re: [go-nuts] SignatureDoesNotMatch error when S3 object name contains “=”

2021-04-15 Thread Jesper Louis Andersen
On Thu, Apr 15, 2021 at 7:01 PM nonnikcm wrote: > i am struggling with using the s3manager to create files on S3. the file > names need to be in the following format "set=2012-04-3", containing an > "=". uploading with out the "=" works perfectly... > sess := session.Must(session.NewSession()) up

Re: [go-nuts] Case for Cond.WaitTimeout()

2021-04-14 Thread Jesper Louis Andersen
On Tue, Apr 13, 2021 at 3:00 PM Roman Leventov wrote: > Jesper, a single channel works if I provision it with big enough capacity > (1000), but this feels like an antipattern which can break. > Yes. On the flip side though, unbounded channels are also dangerous if the producer(s) outpaces consu

Re: [go-nuts] Case for Cond.WaitTimeout()

2021-04-13 Thread Jesper Louis Andersen
On Tue, Apr 13, 2021 at 12:53 PM Roman Leventov wrote: > type Frame struct{} > > type Connection struct { > sem*semaphore.Weighted // from http://golang.org/x/sync/semaphore > mu sync.Mutex > frames []*Frame > } > > My immediate hunch when reading your code was: type Connection struct {

Re: [go-nuts] go text://protocol client?

2021-04-11 Thread Jesper Louis Andersen
On Sun, Apr 11, 2021 at 5:11 AM Kurtis Rader wrote: > > It is nice that the specification allows for an efficient implementation. > But I agree with Dan that your documentation is opaque, obtuse, > inscrutable, etc. So much so that I initially thought it was some sort of > April Fools Day joke. >

Re: [go-nuts] go text://protocol client?

2021-04-09 Thread Jesper Louis Andersen
On Fri, Apr 9, 2021 at 5:37 PM 'Petite Abeille' via golang-nuts < golang-nuts@googlegroups.com> wrote: > > Would you know of any go text://protocol clients? Or servers? > > No, but it would be a fairly good beginner project[0] [0] Readers of the erlang-questions@ mailing list would know :P -- Y

Re: [go-nuts] Why does my code keep giving me "socket: too many open files"

2021-04-09 Thread Jesper Louis Andersen
On Fri, Apr 9, 2021 at 7:20 PM Tenjin wrote: > Basically I am making a script to query an api for some json data, if I > run it synchronously it works fine and works as intended but it needs to do > this give or take 15thousand times so I thought I would use concurrency to > get the job done. It

Re: [go-nuts] Designing a recurring event with timeouts using channels

2021-04-09 Thread Jesper Louis Andersen
On Thu, Apr 8, 2021 at 8:15 PM Arya wrote: > There are a few things that I am worried about in the above given snippet. > The first thing is whether I am in alignment with golang's idioms while > modeling this process using channels and the second thing is where I am > resetting the voteStatusCha

Re: [go-nuts] How to wait for HTTP server to start?

2021-03-29 Thread Jesper Louis Andersen
On Sat, Mar 27, 2021 at 3:19 PM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > The best way to do it is probably by making an HTTP request and see if it > succeeds. In production, it's always a good idea to have a health check > endpoint anyways. So some service manager can

Re: [go-nuts] Re: A message from the CoC committee

2021-03-25 Thread Jesper Louis Andersen
On Wed, Mar 24, 2021 at 8:18 PM ben...@gmail.com wrote: > I'm comparing to various legal systems, in which there is almost always > the possibility of appeal, even for heinous crimes. > It's somewhat the other way around. The worse the crime, the more argument for an appeal process because you c

Re: [go-nuts] Golang Problems

2021-02-28 Thread Jesper Louis Andersen
You've stated the assignment. What have you tried in order to solve it? The best way to get at this is to just jump out in it and start trying stuff and see when it fails. Don't be afraid of stuff falling apart in the beginning. That's not what you are going to hand in, anyway. In addition, we do

Re: [go-nuts] big.Float.Cmp does not work as expected

2021-02-15 Thread Jesper Louis Andersen
On Sun, Feb 14, 2021 at 9:20 PM Santhosh Kumar T wrote: > I created: > one instance using big.NewFloat function > another instance using big.Float.SetString method > > Adding to this: Generally, comparing FP values for equality can give results you don't expect due to the way numerics fo

Re: [go-nuts] Recommendation for Fuzzed Types without Native On-Disk Format

2021-02-11 Thread Jesper Louis Andersen
On Mon, Feb 8, 2021 at 10:07 PM Matt Proud wrote: > Suppose I am interested in fuzz testing an API using dvyukov/go-fuzz > , and the primary API under test > accepts relatively complex composite data types itself: func F(*Table) > error, where the types below a

Re: [go-nuts] Virtual time for testing

2021-01-29 Thread Jesper Louis Andersen
On Thu, Jan 28, 2021 at 10:15 PM Christian Worm Mortensen wrote: > Suppose I want to unit test this function: > > func generator() <-chan int { > ret := make(chan int) > go func() { > for i := 0; i < 10; i++ { > ret <- i > time.Sleep(time.Second) > } > }() > return ret > } > > What is a good way

Re: [go-nuts] Quick question about the generics alternatives that have been considered

2021-01-21 Thread Jesper Louis Andersen
On Wed, Jan 20, 2021 at 4:22 PM atd...@gmail.com wrote: > It' has probably been discussed somewhere but I am curious about what > might have been the issues when considering an implementation of generics > that would parameterized packages? > > You can take a look at Standard ML / Ocaml "functors

Re: [go-nuts] JSON dictionary encoding

2021-01-04 Thread Jesper Louis Andersen
On Mon, Jan 4, 2021 at 8:09 PM ChrisLu wrote: > Hi, > > For a list of json objects, the key names are usually repeated. > e.g., {:1, :2},{:2, :3}, ... > > The key names, "" and "" for the above example, could be very long. > Is there any existing library already encode jso

Re: [go-nuts] Generics - please provide real life problems

2021-01-04 Thread Jesper Louis Andersen
On Mon, Jan 4, 2021 at 9:20 AM Volker Dobler wrote: > On Sunday, 3 January 2021 at 18:43:22 UTC+1 ren...@ix.netcom.com wrote: > >> I do believe (hope) David was kidding. Anonymous product types (and >> similar constructs) are the root of all evil. >> > > Yes, you need dependent product types. Esp

Re: [go-nuts] Generics - please provide real life problems

2021-01-04 Thread Jesper Louis Andersen
On Sun, Jan 3, 2021 at 6:32 PM roger peppe wrote: > FWIW I'm certain that the lack of tuples in Go was a very deliberate > decision - one of Go's more significant ancestors, Limbo, had tuples. > Anonymous product types have their disadvantages too (you don't get to > name the members, so code can

Re: [go-nuts] Generics - please provide real life problems

2021-01-03 Thread Jesper Louis Andersen
On Thu, Dec 31, 2020 at 9:45 PM da...@suarezhouse.net wrote: > Real use cases have been provided it appears for both why generics can be > good and how they can be used negligently (love the sextuple example BTW). Some future language will invent the idea that you should be able to create anony

Re: [go-nuts] Generics - please provide real life problems

2020-12-30 Thread Jesper Louis Andersen
On Wed, Dec 30, 2020 at 3:37 PM Jan Mercl <0xj...@gmail.com> wrote: > > Don't get me wrong. No doubt there are use cases which cannot be > solved reasonably without generics. No doubt there are many other > cases where generics will be an elegant and still readable solution > either. > > I don't d

Re: [go-nuts] Generics - please provide real life problems

2020-12-30 Thread Jesper Louis Andersen
On Sun, Dec 27, 2020 at 7:51 PM Jan Mercl <0xj...@gmail.com> wrote: > On Sun, Dec 27, 2020 at 3:51 PM Jesper Louis Andersen > wrote: > > > I need a heap over any type which can be ordered, and its needs to drag > around any type of satellite data. > > I'

Re: [go-nuts] Generics - please provide real life problems

2020-12-27 Thread Jesper Louis Andersen
On Thu, Dec 24, 2020 at 7:15 AM Martin Hanson wrote: > I therefore propose that the pro-generics camp provide real examples of > problems they have faced that was such a big issue that it justifies > adding generics to Go. > > Maintaining type safety is a lot easier with generics. Right now, my c

Re: [go-nuts] Is it possible that a hybrid memory management could be implemented?

2020-11-16 Thread Jesper Louis Andersen
On Mon, Nov 16, 2020 at 4:04 PM tapi...@gmail.com wrote: > > I feel there still room between the two to explore, though I have not a > clear thought on this yet. > Many of the tricks tend to coincide with both allocator strategies as you work more on them. The methods are much more two sides of

Re: [go-nuts] Re: How does the Golang compiler handle dependencies?

2020-11-14 Thread Jesper Louis Andersen
On Sat, Nov 14, 2020 at 2:54 AM kev kev wrote: > Oh right, I seem to not understand why golang is faster in that respect. > If you can include the precompiled headers and or have an object file > > The key point is that in C++, declarations in header files tend to be leaky, especially in larger p

Re: [go-nuts] How to drop old value in a channel salety

2020-11-13 Thread Jesper Louis Andersen
On Fri, Nov 13, 2020 at 8:12 AM 陶青云 wrote: > > It is not a one-length buffered channel. I need to drop because the > recveiver do heavy work that can't process as quickly as sender. > You need to write a flow control scheme then. Channels may be part of the solution, but they can't solve it on

Re: [go-nuts] Re: Register spilling size

2020-11-04 Thread Jesper Louis Andersen
On Wed, Nov 4, 2020 at 9:36 AM eric...@arm.com wrote: > I got it, the code is here > https://github.com/golang/go/blob/633f9e206045176a12c301eb2c249c1c1d9a5d2e/src/cmd/compile/internal/gc/pgen.go#L186 > , > I don't know why the slot is required to be aligned at least 8 bytes on > these architectu

Re: [go-nuts] Does concurrency have some effect over HTTP client?

2020-10-27 Thread Jesper Louis Andersen
On Mon, Oct 26, 2020 at 8:21 PM JuanPablo AJ wrote: > Jesper, > thanks a lot for your email, your answer was a hand in the dark forest of > doubts. > > I will start trying the load generator wrk2. > > About "instrument, profile, observe", yes, I added the gops agent but > until now I don't have a

Re: [go-nuts] Should I always call runtime.LockOSThread() before calling C function?

2020-10-26 Thread Jesper Louis Andersen
On Sun, Oct 25, 2020 at 7:20 PM Tamás Gulácsi wrote: > I'd put all that C-calling code in ONE goroution, with > runtime.LockOSThread, and send commands to this thread through a channel, > with a receiver chan for response, too. > This way only one goroutine needs LockOSThread, and only that pays

Re: [go-nuts] Does concurrency have some effect over HTTP client?

2020-10-25 Thread Jesper Louis Andersen
On Sat, Oct 24, 2020 at 7:30 PM JuanPablo AJ wrote: > I have some doubts related to the HTTP client. > First, if you have unexplained efficiency concerns in a program, you should profile and instrument. Make the system tell you what is happening rather than making guesses as to why. With that s

Re: [go-nuts] Re: differentiate if a value was set or not

2020-10-23 Thread Jesper Louis Andersen
On Fri, Oct 23, 2020 at 12:17 AM Ian Lance Taylor wrote: > So there are several possible approaches. I'm guessing you want one > that is more implicit, but as a general guideline Go tends to prefer > explicit code. > > I don't think there is a good implicit approach to this problem. If you have

Re: [go-nuts] Golang slow performance inside for loop MySQL Queries

2020-10-22 Thread Jesper Louis Andersen
On Tue, Oct 20, 2020 at 6:51 PM wrote: > var count int > var favorited string > > fetchBookmarks := Config.DB.QueryRow("SELECT COUNT(*) FROM > favorites where userID = ? and postID = ? and status = ?", userID, postID, > "added").Scan(&count) > > if fetchBookmarks !

Re: [go-nuts] schedule a job executing in future

2020-10-19 Thread Jesper Louis Andersen
On Mon, Oct 19, 2020 at 9:51 AM Zhihong GUO wrote: > > I am implementing a reminder system. The purpose is to provide API to > client App to add a meeting, and before X minutes the meeting is to open, > the reminder system can send notif to user by SMS or email. Here I need a > function like: whe

Re: [go-nuts] [CODE REVIEW] How to improve structure of Service and DAO Layers

2020-10-12 Thread Jesper Louis Andersen
On Wed, Aug 19, 2020 at 6:38 PM Karan Singh wrote: > *https://play.golang.org/p/Wm9qubLJIGM > * > > Rough comments: 1. I tend to shy away from packages named "utils" since they often attract functions from all over the place of a project. It is often better

Re: [go-nuts] Can ".." occur in golang source?

2020-10-07 Thread Jesper Louis Andersen
On Wed, Oct 7, 2020 at 10:29 AM Ryan Keppel wrote: > Yes, I mean that code section. I did a quick test and two floats tokenizes > just fine (2..5 tokenizes to "2." and ".5")--it doesn't invoke the > described code. I don't think Go in practice would allow two dot tokens in > a row. Go's parser is

Re: [go-nuts] Re: Proper way of mocking interfaces in unit tests - the golang way

2020-10-06 Thread Jesper Louis Andersen
On Mon, Oct 5, 2020 at 3:03 PM 'Bryan C. Mills' via golang-nuts < golang-nuts@googlegroups.com> wrote: > > The core of the problem is that `assert` functions generally *cannot* provide > enough context to produce useful test failures >

Re: [go-nuts] Proper way of mocking interfaces in unit tests - the golang way

2020-10-04 Thread Jesper Louis Andersen
On Thu, Oct 1, 2020 at 6:25 PM Krishna C wrote: > > For unit tests, we need to mock the dependent interfaces either by > creating our own mock implementation of the interface or by using third > party packages like *testify/mocks.* > > Is there any particular reason as to why you want to mock dep

Re: [go-nuts] error types/strings and errors.Is

2020-09-30 Thread Jesper Louis Andersen
On Wed, Sep 30, 2020 at 11:27 AM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Perhaps they haven't because different systems return different ones in >> different circumstances, but I hope Posix means that isn't the case. >> > > Not all platforms Go runs on are Posix. Pla

Re: [go-nuts] Evaluation order of return

2020-09-23 Thread Jesper Louis Andersen
On Wed, Sep 23, 2020 at 10:09 AM cs.ali...@gmail.com < cs.alikoyu...@gmail.com> wrote: > Is there a paper that I can find why the compiler considers them for > ordering, why it is important for performance or anything else? > > A CPU has a limit to how many load/store instructions it can issue in

Re: [go-nuts] Re: Get request send me hmtl content but works fine from python and curl

2020-09-20 Thread Jesper Louis Andersen
On Sun, Sep 20, 2020 at 8:10 AM burak serdar wrote: > A GET request does not have a body. > > Murky waters ahead. RFC 2616 explicitly states that a supplied body SHOULD be forwarded by the server on any request type. This has led some people to use bodies on GET requests; ElasticSearch I'm looki

Re: [go-nuts] Q about memory allocation/cleanup with interfaces

2020-09-13 Thread Jesper Louis Andersen
On Sun, Sep 13, 2020 at 1:42 PM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > Second, garbage collection must run. It runs periodically, but it can take > some time before it does so, and if you check memory usage right after > you've freed up data, it mi

Re: [go-nuts] Q about memory allocation/cleanup with interfaces

2020-09-13 Thread Jesper Louis Andersen
It is perhaps easiest if I go through the conditions which must be met for data to be reclaimed by the Operating System: First, the data must be unreachable by goroutines through a path of pointers. When you nil the object, you break such a path, but you must make sure there are no other such path

Re: [go-nuts] Dynamic composition of interfaces at runtime?

2020-09-02 Thread Jesper Louis Andersen
Usually, my experience is that these highly dynamic interfaces is an indication you want to approach the problem from a different angle. You will converge on something that gets closer and closer to having an interface{}, and this means you are converging toward a world of dynamic typing. It often

Re: [go-nuts] Unique GO language features

2020-08-24 Thread Jesper Louis Andersen
On Fri, Aug 21, 2020 at 7:16 PM joseph.p...@gmail.com < joseph.p.mcguc...@gmail.com> wrote: > > > The feature where GO performs escape analysis and promotes stack variables > to the heap: Did that originate with GO or was it first implemented > elsewhere? > > As Ian says, this is a "rather old" tr

Re: [go-nuts] Memory synchronization by channel operations and mutexes

2020-08-17 Thread Jesper Louis Andersen
On Mon, Aug 17, 2020 at 12:54 PM leo.b...@npo-data.nl < leo.bal...@npo-data.nl> wrote: > Thanks. So I take it this must be handled by the compiler when generating > assembly. > > Yes. The compiler generally follows the Go Memory Model reference specification: https://golang.org/ref/mem > E.g. A

Re: [go-nuts] Newbie question about type-casts

2020-08-04 Thread Jesper Louis Andersen
On Tue, Aug 4, 2020 at 12:31 PM Martin Møller Skarbiniks Pedersen < traxpla...@gmail.com> wrote: bet := int64(math.Ceil(float64(cash)/float64(4))) > > Programming languages must make a conscious choice here. Do we make type casts explicit or implicit? Go opted for the explicit approach, probably b

Re: [go-nuts] import a file

2020-07-30 Thread Jesper Louis Andersen
On Thu, Jul 30, 2020 at 12:54 PM Volker Dobler wrote: > You dop not import files and you do > not run files and you do not test files. Files contain the > sources but are basically uninteresting: Focus on > packages (and modules). > In Go, we disconnect the name of a file and the package in whic

Re: [go-nuts] [Generics] Constraints package name

2020-07-26 Thread Jesper Louis Andersen
On Sun, Jul 26, 2020 at 9:30 AM wrote: > The package name "constraints" is quite a mouthful to read: > > func Min[Elem constraints.Ordered](s []Elem) Elem {} > > Did you consider other package names like "is"? > > func Min[Elem is.Ordered](s []Elem) Elem {} > > You can always solve that with

Re: [go-nuts] Busy synchronization wait seems to behave differently on 1.13 and 1.14

2020-07-25 Thread Jesper Louis Andersen
This is probably due to improvements in preemption. Garbage collectors often need some linearizable checkpoint (or an atomic commit point) where every CPU core agrees on a state. For instance, enabling a write barrier on the heap. Back in the day, this was achieved on communication via channels,

Re: [go-nuts] Allocating lots (e.g. a million) objects on the heap

2020-07-22 Thread Jesper Louis Andersen
On Mon, Jul 20, 2020 at 7:34 PM wrote: > I have an application where I will be allocating millions of data > structures, all of the same size. My program will need to run continuously > and be pretty responsive to > its network peers. > > I'd recommend quantifying "pretty responsive" in this case

Re: [go-nuts] what is walk(fn *Node) for?

2020-07-20 Thread Jesper Louis Andersen
>From a quick glance that might be wrong: It looks like the walk function visits an abstract syntax tree (AST) and performs checks for the statics part of the compiler. E.g., it finds unused variables and functions, type-illegal statements and so on. The term "walk" is used as in that it "walks ov

Re: [go-nuts] [generics] Was "no type contracts" considered?

2020-07-18 Thread Jesper Louis Andersen
On Sat, Jul 18, 2020 at 1:55 PM Markus Heukelom wrote: > Concerning the current generics proposal, was it every considered to not > allow type contracts at all? > > No type contracts would mean that generic functions can only use =, & on > variables of parametric types, as these are always availa

Re: [go-nuts] where is temp file created by http server

2020-07-16 Thread Jesper Louis Andersen
They will be removed once the request finishes. The way to access them is usually by the FormFile method on *http.Request or to create a multipart reader and break it out yourself. The reason the latter is interesting is because it can avoid storing data you are not prepared to handle. On Thu, Ju

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jesper Louis Andersen
On Wed, Jul 15, 2020 at 11:27 AM Randall O'Reilly wrote: > wouldn't gofmt remove the superfluous (z) in this case (and even with a > more complex expression inside the parens, as the > operator would have > appropriate precedence?), in existing code? And thus, would it not be > reasonable to hav

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jesper Louis Andersen
On Wed, Jul 15, 2020 at 10:47 AM Nick Craig-Wood wrote: > In my mind the use of [ ] clashes horribly with the array declaration > syntax. When I see [int] in particular my brain says, ah array declaration > of size int, what, no wait... > > This makes [identifier] mean two different things depen

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jesper Louis Andersen
On Wed, Jul 15, 2020 at 8:25 AM Michael Jones wrote: > nice. "gen" here is akin to the existing forward declaration of recursive > inner functions. it says, "you are about to see something special and you > need to know *this* about it." > > The real name is "forall", and it presents a binding si

Re: [go-nuts] [generics] Data structures and the garbage collector

2020-07-10 Thread Jesper Louis Andersen
On Thu, Jul 9, 2020 at 6:40 PM Markus Heukelom wrote: > Many data structures are implemented using pointers. How does this perform > wrt garbage collecting? For example take any data structure that uses some > tree of nodes, or even simpler just a singly linked list: there is one > pointer from t

Re: [go-nuts] pure function on golang

2020-07-08 Thread Jesper Louis Andersen
On Mon, Jul 6, 2020 at 6:46 PM wrote: > > to my understanding, a pure function is a function that doesn't have a > side effect, so we can limit pure function to: > - unable to call non-pure function > - unable to modify a variable that is not declared on current function > (like a global variable

Re: [go-nuts] [runtime] Scheduling overhead incurred by the runtime

2020-06-25 Thread Jesper Louis Andersen
On Tue, Jun 23, 2020 at 6:33 PM Deepak Sirone wrote: > > Process A sends a message to B using the "encoding/gob" package to write > to the socket which is subsequently decoded. After sending a message, A > waits for a response from B. B does some processing on the message and > sends a reply back

Re: [go-nuts] Go has eliminated most of my off-by-one errors except 0... I mean 1.

2020-06-22 Thread Jesper Louis Andersen
On Sat, Jun 13, 2020 at 4:42 PM Tom Limoncelli wrote: > I've been coding for a few years (first line of BASIC was in September > 1979) and I have to admit that off-by-one errors have always been a > problem for me. I guess I'm just that kind of sloppy. > > They are surprisingly common! It has to

Re: [go-nuts] x, err = some_func(); if err != nil { } seems awkward

2020-06-22 Thread Jesper Louis Andersen
On Thu, Jun 4, 2020 at 8:42 PM Michael Jones wrote: > > For that to work, it means that a function call either succeeds or fails. > If it succeeds, then that's that. If it fails, then something special > happens. Your "#" means "do this only if the function call failed." In that > case itmust be

Re: [go-nuts] Re: [generics] I think it's better have higher perfomance than lower compiling time

2020-06-22 Thread Jesper Louis Andersen
On Fri, Jun 19, 2020 at 8:13 PM wrote: > We have seen performance decreases in some language versions, but we have > also seen performance increases. Efficient execution is a project goal, but > efficient compilation is as well, so I would not recommend hoping for or > expecting that performance

Re: [go-nuts] [generics] Thank you Go team

2020-06-19 Thread Jesper Louis Andersen
On Fri, Jun 19, 2020 at 4:16 AM Michael Jones wrote: > Really smart and accomplished people have worked for a year to refine the > generics approach--as the impressive updated design draft and the scholarly > FeatherweightGo paper both demonstrate. The design is accompanied with > tools to allow

Re: [go-nuts] [generics] the empty type list

2020-06-19 Thread Jesper Louis Andersen
On Thu, Jun 18, 2020 at 10:14 PM Axel Wagner wrote: > These arguments would be more convincing, if Go wouldn't already reject > interfaces impossible to implement: https://play.golang.org/p/dYm8js26qml > > In my experience, trying to reject the degenerate corner cases in logic is only going to hu

Re: [go-nuts] [generics] Replace () with <> or other character

2020-06-18 Thread Jesper Louis Andersen
On Thu, Jun 18, 2020 at 6:38 PM Brian Zhao wrote: > Would something similar work in go's parser? I'm personally in favor of > the <> syntax, since it's very similar to other languages (C++, Swift, > Rust, Java, C#). > > It is just another parameter. I wouldn't give it special syntactical treatmen

Re: [go-nuts] [generics] the empty type list

2020-06-18 Thread Jesper Louis Andersen
It is a type which cannot be inhabited by a term. These exist and often have uses. As Bryan wrote they also completes the type lattice, so rejecting them is often a lot of work for little gain. If you want examples, look up phantom types, where an uninhabited type is used as a tag for ensuring com

Re: [go-nuts] It is said that future Macs will use ARM, is golang ready for this move ?

2020-06-10 Thread Jesper Louis Andersen
al debug symbols. > > On Jun 10, 2020, at 4:51 AM, Jesper Louis Andersen < > jesper.louis.ander...@gmail.com> wrote: > >  > I'd say Go is as ready as you can be for that move. darwin/arm64 is > currently a fully supported architecture, and I doubt you need lots of work &g

Re: [go-nuts] It is said that future Macs will use ARM, is golang ready for this move ?

2020-06-10 Thread Jesper Louis Andersen
I'd say Go is as ready as you can be for that move. darwin/arm64 is currently a fully supported architecture, and I doubt you need lots of work in order to make the port to an eventual new Mac generation. By far the most complex part of that port is support of arm64, but that work has already been

Re: [go-nuts] golang protobuf, struct copy problem

2020-05-20 Thread Jesper Louis Andersen
As a general rule, be cautious when your external data representation is one-to-one with your internal data representation. There is a risk of tight coupling in this case. The wire format is not always how you want to handle data internally in the application. The lure is that you can build a syste

Re: [go-nuts] json decode is very slow

2020-05-03 Thread Jesper Louis Andersen
7;t be observed at the > application level. Correct me if I'm wrong. > > Regards > > On Thu, Apr 30, 2020 at 2:34 PM Jesper Louis Andersen < > jesper.louis.ander...@gmail.com> wrote: > >> On Tue, Apr 28, 2020 at 6:48 PM Sarath Prabath Redlapalli Jaya < >&g

Re: [go-nuts] json decode is very slow

2020-04-30 Thread Jesper Louis Andersen
On Tue, Apr 28, 2020 at 6:48 PM Sarath Prabath Redlapalli Jaya < harrysarath2...@gmail.com> wrote: > We've instrument the above code block and reading request body bytes is > taking very long i.e., upto 5 secs sometimes reaching upto 20 seconds at the > throughput of ~4-5K RPM > > > The Request

Re: [go-nuts] Can someone please explain http.HandlerFunc() ?

2020-04-04 Thread Jesper Louis Andersen
The function `notfound` is a plain function. It has a specific signature, (w http.ResponseWriter, r *http.Request). There is a type, HandlerFunc, with the following specification: type HandlerFunc func(ResponseWriter, *Request) Types in Go are "generative", so the HandlerFunc type is different fr

Re: [go-nuts] SFTPGo: a Golang performance story and some questions

2020-03-13 Thread Jesper Louis Andersen
On Thu, Mar 12, 2020 at 12:45 AM Nicola Murino wrote: > > what I understand reading that issue is that sync.Pool is not the best > choice to store variable-length buffers and my first allocator > implementation accepts buffers of any size, each received packet can > have different sizes (between

Re: [go-nuts] SFTPGo: a Golang performance story and some questions

2020-03-11 Thread Jesper Louis Andersen
On Wed, Mar 11, 2020 at 1:43 PM Nicola Murino wrote: > So I wrote a proof of concept allocator that tries to avoid all these > extra allocations reusing the previously allocated slices: > > https://github.com/drakkan/sftp/blob/master/allocator.go > > Any particular reason you avoided something li

Re: [go-nuts] Re: Changing source code in order code to be supported from older Golang versions e.g. Go 1.10

2020-03-08 Thread Jesper Louis Andersen
On Sun, Mar 8, 2020 at 9:31 AM Amnon Baron Cohen wrote: > > There are many ways could try to "help" Dimitrios find ways to run modern > Go code on XP, and help him > extend the lifetime of his fleet of XP machines. But this would keep his > organisation vulnerable to the next > WannaCry attack. S

  1   2   3   >