Re: [go-nuts] how to get dirt memory in go
Thanks, i'm check вт, 14 янв. 2025 г. в 16:49, Jan Mercl <0xj...@gmail.com>: > > On Tue, Jan 14, 2025 at 2:44 PM Vasiliy Tolstov wrote: > > > Hi! I'm try to search answers but have no luck. In go i can create > > memory arena/ buffer pool etc.. > > But does it possible to get memory with like make([]byte, XXX) but > > without calloc for this memory? > > Not sure if it's what you're after, but maybe take a look at > https://pkg.go.dev/modernc.org/memory -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CACaajQtWh1_r%3DRCZ9TMfuKK3xTQEJUyFmg7FPepDskq7831EAg%40mail.gmail.com.
Re: [go-nuts] Re: how to get dirt memory in go
Thanks, i'm check bench with modernc ср, 15 янв. 2025 г. в 10:57, tapi...@gmail.com : > > see https://go101.org/q-and-a/make-dirty-byte-slices.html > > On Tuesday, January 14, 2025 at 9:44:40 PM UTC+8 Vasiliy Tolstov wrote: >> >> Hi! I'm try to search answers but have no luck. In go i can create >> memory arena/ buffer pool etc.. >> But does it possible to get memory with like make([]byte, XXX) but >> without calloc for this memory? >> >> So i need to get raw memory from kernel without spending time to clearing it. >> >> -- >> Vasiliy Tolstov, >> e-mail: v.to...@selfip.ru > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion visit > https://groups.google.com/d/msgid/golang-nuts/c3473a74-abdd-4870-a453-c9a6b5b635cbn%40googlegroups.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CACaajQt2R_PXvCCYvFFt6BAG-f8rUZ4EQJgC_jhejnN4jJ97BQ%40mail.gmail.com.
[go-nuts] how to get dirt memory in go
Hi! I'm try to search answers but have no luck. In go i can create memory arena/ buffer pool etc.. But does it possible to get memory with like make([]byte, XXX) but without calloc for this memory? So i need to get raw memory from kernel without spending time to clearing it. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuByEWume%2B%3DgUdFhk4zH5r%2BpCDxYMZT_ghinKOKwPn7RA%40mail.gmail.com.
Re: [go-nuts] ANN: selfy for self-signed certs. rpc25519 for blazing QUIC based RPC
Thank you, this is very cool and helpful вт, 22 окт. 2024 г. в 23:51, Jason E. Aten : > > I wrote this RPC package recently: > > https://github.com/glycerine/rpc25519 > > `rpc25519` is a fun little RPC package that I cooked up to > get comfortable with modern (Ed25519) rather than > antiquated (RSA) crypto primitives. > > Along the way I made a very > helpful tool called `selfy`. > It makes generating self-signed > certificate authorities > and self-signed ed25519 keys easy. > Importantly, these certs will > work on any host. So you don't > have to buy a domain > name to deploy certs or this RPC system. > > Other cool things I discovered: > > 1) quic-go QUIC can get way, way more throughput > than Go's TLS stack for lots of short messages > and new connects. Holy cow its > not enough close. TLS over TCP > will start dragging > after 100 connections in a few seconds, but > QUIC just surges through. > Big Kuddos to the QUIC designers > and the quic-go implementers. > https://github.com/quic-go/quic-go > > 2) QUIC is also super fun because its easy to share > a single UDP port for your client and server. This > can make traversing NATs easier. The rpc25519 > package does this by default, so its pretty > easy to set up by copying what it is doing. > See quic_server.go and quic_client.go > > 2.5) The only sadness to QUIC is on VPNs > over IPv6. See the README for notes/cautions > on this. Its nuts to me to realize that > global IPv6 networks can be so poorly setup. > > 3) Setting up symmetric pre-shared keys for > post-quantum safety is not that hard. Inspired > by Wireguard, optionally, inside TLS, I have rpc25519 > do a quick Diffie-Hellman handshake then mix > in the pre-shared key for forward secrecy > over each connection. It is actually very > little code. symmetric.go has it. The > embedded systems guys who need pre-shared key > support may find this a good starting > point. TLS is an awesome beast but > still a beast sometimes in small places. > > 4) The frozen net/rpc standard lib > package is such a tight design. I > really enjoyed reading its code. > Since its frozen is probably not > a great idea to build on it > directly, so I decided to reproduce > its interface. I glued the top layer on as a > second API option, and its kind of fun > to work with. > I also added context.Context > optionally to the server's up-calls > so you can query your net.Conn and > figure out who you are talking to/ > get other meta data. All > in all, kind of delightful. > > Feedback welcome. > > Enjoy, > > Jason > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/bf4411bd-c236-4ef3-8b36-35310478384en%40googlegroups.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuddzW9VRMwEt7LfLAXeLPFou271JejvNOg6pmgFkphMA%40mail.gmail.com.
[go-nuts] Re: custom coverage report
Anybody knows golang package that can write cover files in desired format? вс, 20 авг. 2023 г. в 17:28, Vasiliy Tolstov : > > Hi. I have service centric tests - so i want to test not each function > inside application, but only it handlers (defined via protobuf) > Also i have custom framework that runs each test like - start grpc > server, and call it via predefined json based files, and compare > results. > I want to measure coverage , but don't understand how to do that? > Is that possible to have another way to measure handlers coverage in > case of service defined via protobuf? > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQty5r%2B87t7zT9qa18qEdfFtP%3DcZsOCT9qx9EjeodtCq_Q%40mail.gmail.com.
[go-nuts] custom coverage report
Hi. I have service centric tests - so i want to test not each function inside application, but only it handlers (defined via protobuf) Also i have custom framework that runs each test like - start grpc server, and call it via predefined json based files, and compare results. I want to measure coverage , but don't understand how to do that? Is that possible to have another way to measure handlers coverage in case of service defined via protobuf? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQs36fRvsZPPzkw%3DA2ufpXSi%2BW7fR1gQqWTg4wjhoJtc%3Dg%40mail.gmail.com.
Re: [go-nuts] Re: smarter way to provide interface capabilities from underlining interface
Yes, you are right. Mostly i'm worry about compile/run time. As i see on my mac air m1 compilation on go 1.20 slowdown to 1-2s (i think because file parsing) And don't know about running time of such checks for many interface implementations... I'm try to check in number of interfaces in descending order... But don't understand how this can be optimized... May be run profile with all known sql drivers and create pairs with most used combinations ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru На 11 июня 2023 г., 19:31:01, Brian Candler написали: > I think the issue is that the *consumer* of this object checks whether > certain methods (or rather, interfaces) are present, and behaves > differently depending whether they are or not. > > There are a whole load of public interfaces defined here: > > https://cs.opensource.google/go/go/+/refs/tags/go1.20.5:src/database/sql/driver/driver.go > And the supplied object, which the OP is trying to wrap, could implement > some arbitrary combination of these interfaces. > > I think that for *some* of these interfaces, it would be OK to provide > dummy implementations if there is no underlying method to call: e.g. > > https://cs.opensource.google/go/go/+/refs/tags/go1.20.5:src/database/sql/sql.go;l=552-554 > > https://cs.opensource.google/go/go/+/refs/tags/go1.20.5:src/database/sql/sql.go;l=567-569 > > https://cs.opensource.google/go/go/+/refs/tags/go1.20.5:src/database/sql/sql.go;l=834-838 > > But for others it's much less clear, and it may make a semantic difference > whether the the object you provide implements these interfaces or not, e.g. > > https://cs.opensource.google/go/go/+/refs/tags/go1.20.5:src/database/sql/sql.go;l=1865-1867 > > For these, I can't think of a better implementation that the OP's. It > doesn't seem like the greatest API design though. > > On Sunday, 11 June 2023 at 08:10:01 UTC+1 Tamás Gulácsi wrote: > >> As Far as I See, you check all the combinations of methods in wideness >> order. >> Why not have a generic wrapper struct, that is filled with the underlying >> driver.Conn's methods, >> and use that if not nil, but use the generic implementation if not. >> >> Like >> ``` >> type wrappedConn struct { >> driver.Conn >> queryContext func(...) >> } >> func (wc wrappedConn) QueryContext(...) ... { >> if wc.queryContext != nil { return wc.queryContext(...) } >> return wc.Conn.Query(...) >> } >> ``` >> >> This way you only have to check for each method on driver.Conn, and fill >> the wrappedConn's functions as they axist/not. >> >> Vasiliy Tolstov a következőt írta (2023. június 10., szombat, 12:16:34 >> UTC+2): >> >>> I have sql driver that wraps original driver.Driver, to be able to work >>> with drivers that not have ExecerContext or QuerierContext i need to return >>> wrapped to that supports only needed interfaces. >>> I'm to want to write all cases via handmade switch case and write >>> generator that creates full combo list of methods and generate interfaces >>> for this methods. >>> But this brings file that contains 20K lines >>> https://git.unistack.org/unistack-org/micro-wrapper-sql/src/branch/master/wrap_gen.go >>> Does it possible to have smaller code that provides the same effect? >>> Or I'm miss something? >>> >>> -- >>> Vasiliy Tolstov, >>> e-mail: v.to...@selfip.ru >>> >> -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/4dc775df-6627-4134-8b32-e9f659e48831n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/4dc775df-6627-4134-8b32-e9f659e48831n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQusYK8_QA9ry1Rpq9q%2BJVT7hUeD8Jq8Z7N8Wxn3JLy7Rg%40mail.gmail.com.
[go-nuts] smarter way to provide interface capabilities from underlining interface
I have sql driver that wraps original driver.Driver, to be able to work with drivers that not have ExecerContext or QuerierContext i need to return wrapped to that supports only needed interfaces. I'm to want to write all cases via handmade switch case and write generator that creates full combo list of methods and generate interfaces for this methods. But this brings file that contains 20K lines https://git.unistack.org/unistack-org/micro-wrapper-sql/src/branch/master/wrap_gen.go Does it possible to have smaller code that provides the same effect? Or I'm miss something? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuX2Srh%3D7yWeFQxK_DfhHtWARUp4v7o-rbvagMFwwAy6w%40mail.gmail.com.
Re: [go-nuts] what's the most popular kafka library to use
I'm try all kafka libraries and my list: 1. github.com/twmb/franz-go/kgo - the best, no problems is around 1.5-2 years 2. github.com/segmentio/kafka-go (cool but have some errors 1.5 years ago, so i broke my production cluster with it) -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru На 13 марта 2023 г., 20:43:05, Eli Lindsey написали: > Is there an obvious choice here? what are people using now days (March > 2023) > > > I don’t think there’s an obvious choice, there’s three or four main libs, > any of which may be good for different uses. > > Some color on confluent-kafka-go - it's a wrapper around librdkafka. > librdkafka is the main Kafka C lib and underpins many/most of the non-JVM > language bindings. From that angle, if you’re looking for popularity it > will surpass sarama. It also tends to have more of the esoteric or > long-tail features implemented, though I haven’t done a feature comparison > in awhile and it looks like that’s not relevant to you anyways. However it > comes with the big caveat/potential pain point of requiring cgo. > > segmentio/kafka-go is also worth considering. It’s my main goto if > avoiding cgo. > > -eli > > On Mar 13, 2023, at 12:48 PM, ami malimovka > wrote: > > Currently I'm interested only in consuming/producing. > > I'm aware of *confluent-kafka-go *and of *sarama, *and it looks like > sarama has more github swag, but other than that I have no idea which one > is better/more popular. > > Is there an obvious choice here? what are people using now days (March > 2023) > > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/1f3e2106-9254-453c-905e-d51076210fbbn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/1f3e2106-9254-453c-905e-d51076210fbbn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/3C38837C-3811-4ABF-A6D8-E349FE947FB9%40siliconsprawl.com > <https://groups.google.com/d/msgid/golang-nuts/3C38837C-3811-4ABF-A6D8-E349FE947FB9%40siliconsprawl.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQv%2B%2BHJ-6Yo78oX%2BbNq7ZOt7tUzsZhZVb7XMPzwLxZN52g%40mail.gmail.com.
[go-nuts] allow to use fieldaligment with own golang code
I want to use fieldaligment in own code (mostly i want to align automatic struct fields in generated code). Also i want to reformat generated protobuf code via own tool. I can run fieldaligment.Analyzer but can't set -fix flag because it provided in internal package go/analysis/internal/checker/checker.go i'm also create golang protobuf issue about field alignment because sometimes generated structs have 3x memory usage vs properly aligned struct. What can you suggests ? I don't think that golang protobuf devs fix this in near feature.. or i'm wrong? Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuvQxfaQELJXsrz0X00f6Kvvx89CD77VOvmYu8X7GStwg%40mail.gmail.com.
[go-nuts] question about httputil. NewSingleHostReverseProxy
Hi. I'm use go reverse proxy in some project and have a question https://cs.opensource.google/go/go/+/refs/tags/go1.17.2:src/net/http/httputil/reverseproxy.go;l=323 why headers when copied added to already written? Why copyHeader do Add method for header and not Set ? For example - I have middleware in http server that set some headers, when in some http handler i'm use reverse proxy feature it add other headers from upstream and i have duplicate headers. This is not so bad, but in case of CORS - this breaks. So i need to cleanup headers from upstream before run ServeHTTP from proxy handler. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQu9jAJ%2B_8%2Bui_Aki_ck4Nga_BzViG%3DwoCgBfukZ7Efzyw%40mail.gmail.com.
Re: [go-nuts] macos file provider handling with golang
may be, but i don't understand how to connect it to swift based api and run on m1 macbook пт, 24 сент. 2021 г. в 19:38, Ian Lance Taylor : > > On Fri, Sep 24, 2021 at 9:00 AM Vasiliy Tolstov wrote: > > > > Hi. Does anybody knows how to call macos functions from go? > > Mostly my question about file provider methods, i want to write > > something that works as file provider for macos > > Are you looking for https://golang.org/cmd/cgo? See also > https://go.dev/blog/cgo. > > Ian -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQtQiw4AOM8a%3DkWZb8CtC1xM6Xt2SA8LZBYhLU8%2B5sHmGA%40mail.gmail.com.
Re: [go-nuts] Re: macos file provider handling with golang
thanks, macdriver does not support m1 =) so i can't use it сб, 25 сент. 2021 г. в 08:23, 'Carla Pfaff' via golang-nuts : > > On Friday, 24 September 2021 at 18:00:21 UTC+2 va...@selfip.ru wrote: >> >> Hi. Does anybody knows how to call macos functions from go? >> Mostly my question about file provider methods, i want to write >> something that works as file provider for macos > > > https://github.com/progrium/macdriver > "MacDriver is a toolkit for working with Apple/Mac APIs and frameworks in Go." > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/c9321e1c-2999-4590-a94b-57de6e3e3c59n%40googlegroups.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuJr1WCP_v8UskKFb4W70QrHOL%3DnNgMO9jDorS7fDuhcg%40mail.gmail.com.
[go-nuts] macos file provider handling with golang
Hi. Does anybody knows how to call macos functions from go? Mostly my question about file provider methods, i want to write something that works as file provider for macos -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsDa_7e6x8zVHAsgn_ohjCpVRHGBMTD-h4UEutvxHqaUw%40mail.gmail.com.
Re: [go-nuts] Re: Generating go code using go templates
I'm writing a code generator from protobuf via templates and i can say - debugging it is very hard. When you have big files you can't check syntax easily, don't know how it looks and if you have errors in the template it is really hard to fix them. So the protoc-gen-go case is preferable. вс, 19 сент. 2021 г. в 04:33, Denis Cheremisov : > Templates is the worst approach to code generation IMO. Take a look how > they do this in protoc-gen-go: > > https://github.com/protocolbuffers/protobuf-go/blob/b92717ecb630d4a4824b372bf98c729d87311a4d/cmd/protoc-gen-go/internal_gengo/main.go#L83 > > I am using very similar approach, albeit I prefer format lines, it looks > like: > [image: Screenshot from 2021-09-19 04-22-26.png] > > Templates may be OK only in trivial cases. Once you need something less > trivial it is getting harder and harder to reason how the final code will > look like with them > and you will end up with bunch of hard to manage templates. Unlike it, > line-by-line code generation keep staying close to the final code. > вторник, 7 сентября 2021 г. в 22:53:51 UTC+3, amitl...@gmail.com: > >> >> Hi gophers, >> I wrote https://github.com/fluhus/goat for generating go code in my >> projects. I hope it can help you too. It's a minimal tool that takes a >> text/template <https://pkg.go.dev/text/template> template as input, runs >> it on the given parameters and gofmt's the output. You can also use it on >> non-go-source. >> Feedback is welcome. >> >> Amit >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/406179d9-c8f5-497d-8832-ea04ff9d03b3n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/406179d9-c8f5-497d-8832-ea04ff9d03b3n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuOEDr0zyLeS8%3Dm9Xiy1AU12YkqoMtzVkVueaJmbXQ8XA%40mail.gmail.com.
Re: [go-nuts] write func with optional bool return value
Ok, thank you for the clarification пт, 27 авг. 2021 г. в 18:18, Axel Wagner : > > No, it is not possible. The *only* functions that can return either one or > two returns are builtins. > That's because the number of returns is part of the type of a function, so it > is constant for every function. > Builtin "functions", OTOH, are not really functions, in terms of the > language. They are intrinsics of the compiler, which parses the > call-expression and translates them into machine code or calls into the > runtime (which is also how they can be generic, without Go having generics). > You can see that by trying to assign a builtin function to a variable: > https://play.golang.org/p/0EiSIIqSLhp > This would be possible for every function - but `append` has no type, so you > can't put it in a variable (which would need to have the same type as > `append`). > > What you ask is just categorically impossible in Go. > > On Fri, Aug 27, 2021 at 5:06 PM Vasiliy Tolstov wrote: >> >> I know, so my question is - does it possible to write such functions >> like builtin? For example I can create func via reflect >> >> пт, 27 авг. 2021 г. в 18:03, Levieux Michel : >> > >> > Hi, >> > >> > Optional returns and parameters don't exist in go, what you are referring >> > to is built-in behavior specific to some features. >> > >> > A good way to approach what you want is by assigning it to the anonymous >> > '_' var when you don't want the returned bool. >> > >> > Hope this helps >> > >> > Le ven. 27 août 2021 à 16:58, Vasiliy Tolstov a >> > écrit : >> >> >> >> Does it possible to have own func that have string, bool return value, >> >> but bool value optional? >> >> Like receiving from channel or get element from map, or like when >> >> casting to some type interface? >> >> >> >> -- >> >> Vasiliy Tolstov, >> >> e-mail: v.tols...@selfip.ru >> >> >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> >> "golang-nuts" group. >> >> To unsubscribe from this group and stop receiving emails from it, send an >> >> email to golang-nuts+unsubscr...@googlegroups.com. >> >> To view this discussion on the web visit >> >> https://groups.google.com/d/msgid/golang-nuts/CACaajQvoPEGMM-KB3uRmibXr_HL_aqz_bb2%3DKT%3DsbQKR4U4Gkw%40mail.gmail.com. >> >> >> >> -- >> Vasiliy Tolstov, >> e-mail: v.tols...@selfip.ru >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CACaajQsJ3KeKMStEWvUYtgGnmZMX1gbq_vbt73k6TM2LTkepUA%40mail.gmail.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuMuB0Xip2TCmrrMHt-jPbNsrSYd3ngS0cfTXRWfiK_Nw%40mail.gmail.com.
Re: [go-nuts] write func with optional bool return value
I know, so my question is - does it possible to write such functions like builtin? For example I can create func via reflect пт, 27 авг. 2021 г. в 18:03, Levieux Michel : > > Hi, > > Optional returns and parameters don't exist in go, what you are referring to > is built-in behavior specific to some features. > > A good way to approach what you want is by assigning it to the anonymous '_' > var when you don't want the returned bool. > > Hope this helps > > Le ven. 27 août 2021 à 16:58, Vasiliy Tolstov a écrit : >> >> Does it possible to have own func that have string, bool return value, >> but bool value optional? >> Like receiving from channel or get element from map, or like when >> casting to some type interface? >> >> -- >> Vasiliy Tolstov, >> e-mail: v.tols...@selfip.ru >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CACaajQvoPEGMM-KB3uRmibXr_HL_aqz_bb2%3DKT%3DsbQKR4U4Gkw%40mail.gmail.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsJ3KeKMStEWvUYtgGnmZMX1gbq_vbt73k6TM2LTkepUA%40mail.gmail.com.
[go-nuts] write func with optional bool return value
Does it possible to have own func that have string, bool return value, but bool value optional? Like receiving from channel or get element from map, or like when casting to some type interface? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvoPEGMM-KB3uRmibXr_HL_aqz_bb2%3DKT%3DsbQKR4U4Gkw%40mail.gmail.com.
Re: [go-nuts] Re: sort string slice like it contains key,val
вс, 14 мар. 2021 г. в 01:38, 'Axel Wagner' via golang-nuts : > > One thing I would add is that you'll likely want to use the *Stable versions > of the sort functions, to make sure the order of equivalent elements does not > change. > Apart from that, the solution posted by Carla above with an added step to > remove duplicates seems like the best solution. > Thanks for all help > On Sat, Mar 13, 2021 at 11:27 PM Vasiliy Tolstov wrote: >> >> вс, 14 мар. 2021 г. в 01:10, Brian Candler : >> > >> > If I understand rightly, the values in the slice are to be interpreted >> > (key, value) pairs? In that case, the natural thing to me is to build a >> > map. This also takes care of "duplicate key, last value wins". You can >> > then sort the keys and convert it back: >> > https://play.golang.org/p/dTjmO18T1vQ >> > >> > However, I think that a slice of adjacent keys and values is not a >> > particularly natural way to represent this data; it's clearer to make a >> > structure which holds keys and vals. >> > https://play.golang.org/p/jq358XyKLlx >> > >> >> Yes, but in a small amount of items the operation on slice is faster >> than map. My case - have not more then 16-20 elements >> >> > On Saturday, 13 March 2021 at 13:37:21 UTC va...@selfip.ru wrote: >> >> >> >> Hi! >> >> I'm stuck at sorting stuff like >> >> []string{"xxxkey","xxxval","zzzkey","zzzval","aaakey","aaaval","zzzkey","val"} >> >> i need to get after sorting something like >> >> []string{"aaakey","aaaval", "xxxkey","xxxval","zzzkey","val"} >> >> >> >> So i'm sort by "key" and if key is duplicated - last wins. >> >> Mostly i want to avoid creating helper slices that contains keys and >> >> vals dedicated, does it possible to do sorting only by swapping >> >> "key/val" ? >> >> >> >> -- >> >> Vasiliy Tolstov, >> >> e-mail: v.to...@selfip.ru >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to golang-nuts+unsubscr...@googlegroups.com. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msgid/golang-nuts/8eaa86e7-8787-4fc3-bed6-761586825cefn%40googlegroups.com. >> >> >> >> -- >> Vasiliy Tolstov, >> e-mail: v.tols...@selfip.ru >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CACaajQvwWX3N0tczs31Jka%3D2UDD_kK2SN-QYJTS_eO46cLAyuQ%40mail.gmail.com. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEpv3MD_AA5SoVGViPxwrW-Tg_h1xbWo7D7tHhFjR88%3DQ%40mail.gmail.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvW9eaTDEFGgwSDN-vb9UMk1NMis68VBKf4k-w_%3Dw_DuQ%40mail.gmail.com.
Re: [go-nuts] Re: sort string slice like it contains key,val
вс, 14 мар. 2021 г. в 01:10, Brian Candler : > > If I understand rightly, the values in the slice are to be interpreted (key, > value) pairs? In that case, the natural thing to me is to build a map. This > also takes care of "duplicate key, last value wins". You can then sort the > keys and convert it back: > https://play.golang.org/p/dTjmO18T1vQ > > However, I think that a slice of adjacent keys and values is not a > particularly natural way to represent this data; it's clearer to make a > structure which holds keys and vals. > https://play.golang.org/p/jq358XyKLlx > Yes, but in a small amount of items the operation on slice is faster than map. My case - have not more then 16-20 elements > On Saturday, 13 March 2021 at 13:37:21 UTC va...@selfip.ru wrote: >> >> Hi! >> I'm stuck at sorting stuff like >> []string{"xxxkey","xxxval","zzzkey","zzzval","aaakey","aaaval","zzzkey","val"} >> i need to get after sorting something like >> []string{"aaakey","aaaval", "xxxkey","xxxval","zzzkey","val"} >> >> So i'm sort by "key" and if key is duplicated - last wins. >> Mostly i want to avoid creating helper slices that contains keys and >> vals dedicated, does it possible to do sorting only by swapping >> "key/val" ? >> >> -- >> Vasiliy Tolstov, >> e-mail: v.to...@selfip.ru > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/8eaa86e7-8787-4fc3-bed6-761586825cefn%40googlegroups.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvwWX3N0tczs31Jka%3D2UDD_kK2SN-QYJTS_eO46cLAyuQ%40mail.gmail.com.
Re: [go-nuts] sort string slice like it contains key,val
вс, 14 мар. 2021 г. в 00:41, Robert Engels : > > That wasn’t specified in the assignment :) =) As always after first stuff i need the second =) > > On Mar 13, 2021, at 2:59 PM, Levieux Michel wrote: > > > Your need is not only to sort your data elements then..? > Using the previously advised solution you can just range the slice *after* > you sort it, so you can just check for the next element, which I'd say is not > *too bad*, what are your performance constraints? > > Le sam. 13 mars 2021 à 21:33, Vasiliy Tolstov a écrit : >> >> Looks fine =) But how to remove duplicates? >> I'm found this stuff >> https://github.com/campoy/unique/blob/master/unique.go but as i >> understand it needs to adapt to my case =) >> >> сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts >> : >> > >> > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: >> >> >> >> the sort package from the stdlib, it contains an interface that you can >> >> easily implement for such problematics :) >> > >> > >> > Like this: https://play.golang.org/p/eoLJ2aVAWkD >> > >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to golang-nuts+unsubscr...@googlegroups.com. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msgid/golang-nuts/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com. >> >> >> >> -- >> Vasiliy Tolstov, >> e-mail: v.tols...@selfip.ru >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%40mail.gmail.com. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAL4P9zwK5vh1cwmq0yrCVuJsNCg0WXqfhZuXg%2BgV2MTFO--KvQ%40mail.gmail.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuqPZyUt1QWU8T9O46JcgUSq72%2B_FSajxeQWrV5SGGHZw%40mail.gmail.com.
Re: [go-nuts] sort string slice like it contains key,val
I think that remove after sort is good for me, thanks сб, 13 мар. 2021 г. в 23:59, Levieux Michel : > > Your need is not only to sort your data elements then..? > Using the previously advised solution you can just range the slice *after* > you sort it, so you can just check for the next element, which I'd say is not > *too bad*, what are your performance constraints? > > Le sam. 13 mars 2021 à 21:33, Vasiliy Tolstov a écrit : >> >> Looks fine =) But how to remove duplicates? >> I'm found this stuff >> https://github.com/campoy/unique/blob/master/unique.go but as i >> understand it needs to adapt to my case =) >> >> сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts >> : >> > >> > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: >> >> >> >> the sort package from the stdlib, it contains an interface that you can >> >> easily implement for such problematics :) >> > >> > >> > Like this: https://play.golang.org/p/eoLJ2aVAWkD >> > >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to golang-nuts+unsubscr...@googlegroups.com. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msgid/golang-nuts/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com. >> >> >> >> -- >> Vasiliy Tolstov, >> e-mail: v.tols...@selfip.ru >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%40mail.gmail.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsbvy9ofxGhSfOoBBQNxtPQnXxZtm2kfiEWyZ4goiwwtw%40mail.gmail.com.
Re: [go-nuts] sort string slice like it contains key,val
Looks fine =) But how to remove duplicates? I'm found this stuff https://github.com/campoy/unique/blob/master/unique.go but as i understand it needs to adapt to my case =) сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts : > > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: >> >> the sort package from the stdlib, it contains an interface that you can >> easily implement for such problematics :) > > > Like this: https://play.golang.org/p/eoLJ2aVAWkD > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%40mail.gmail.com.
[go-nuts] sort string slice like it contains key,val
Hi! I'm stuck at sorting stuff like []string{"xxxkey","xxxval","zzzkey","zzzval","aaakey","aaaval","zzzkey","val"} i need to get after sorting something like []string{"aaakey","aaaval", "xxxkey","xxxval","zzzkey","val"} So i'm sort by "key" and if key is duplicated - last wins. Mostly i want to avoid creating helper slices that contains keys and vals dedicated, does it possible to do sorting only by swapping "key/val" ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQt82U878secmTSPaFW85a%3DWA20-vF%2BsPub%2B_w3i%3DohtEA%40mail.gmail.com.
[go-nuts] best way and race free case to transfer some value in context to caller
Hi. i have func like func AAA(ctx context.Context, req interface{}) error {} inside func i need to return some value not via error, but in context (as i only one way do do that) I'm write something like code below. I can't transfer code inside error, because it predefined struct (generated from protobuf) and i cant use grpc Outcoming context and grpc as this is not grpc server/client code. What the best way? And the next question - does it possible to clone context with all deadlines and internal stuff without creating some struct that satisfies context and uses in as parentheses? ```go type rspCodeKey struct{} type rspCodeVal struct { code int } func SetRspCode(ctx context.Context, code int) { if rsp, ok := ctx.Value(rspCodeKey{}).(*rspCodeVal); ok { rsp.code = code } } func GetRspCode(ctx context.Context) int { var code int if rsp, ok := ctx.Value(rspCodeKey{}).(*rspCodeVal); ok { code = rsp.code } return code } ``` -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQviZSyY5V0DQWRrSCh0FQm8_wJv56b6hmUL%2B1mgLSFm9Q%40mail.gmail.com.
[go-nuts] return own custom error from template while it executed
Hi. I can't find in google how to solve my problem. Inside text/template i want to check some passed data and return some descriptive text if conditions not matching. I don't have ability to check it before template executed. Does it possible? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuGhatY-vr-DoQ37t-bNHbaVC8f%2B-gJHiqqFKqgMxjRgg%40mail.gmail.com.
Re: [go-nuts] Re: protobuf avoid namespace conflict
server https://github.com/unistack-org/micro-server-grpc client https://github.com/unistack-org/micro-client-grpc code used both repos https://github.com/unistack-org/micro-tests/tree/master/server/grpc ср, 30 сент. 2020 г. в 16:41, Joop Kiefte : > This seems to be because the protocol buffer packages rely on shared > state, kinda similar to the registration of database drivers in > database/sql I would say (correct me if I'm wrong). I don't know how you > import them, but you probably need a way to strictly separate the two in > your program (example code would help to give more specific advice...). > > *Joop Kiefte* - Chat @ Spike > <https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=pgfpn> [image: > pgfpn] > > On September 30, 2020 at 13:26 GMT, Vasiliy Tolstov > wrote: > > > So nobody knows how to deal with this? And if some projects have proto > files with the same name - protobuf always complain about it? > > вт, 29 сент. 2020 г. в 10:50, Vasiliy Tolstov : > > > > Hi! I have two packages server and client. All belongs to different > > repos. In this packages i have internal/errors dir with errors.proto > > file > > Both of them contains go_package option and package unique > > > > option go_package = "xxx.org/server/internal/errors"; > > package server.errors; > > > > option go_package = "xxx.org/client/internal/errors"; > > package client.errors; > > > > why program that used client and server in the same time have such > message > > > > 2020/09/29 10:50:18 WARNING: proto: file "errors.proto" is already > registered > > previously from: ""xxx.org/server/internal/errors" > > currently from: ""xxx.org/client/internal/errors" > > A future release will panic on registration conflicts. See: > > > https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict > > > > -- > > Vasiliy Tolstov, > > e-mail: v.tols...@selfip.ru > > > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CACaajQvaGd8j2MD75EkRvH6zxD89gyKLunxXL6Q5%3DN9VkKWWhQ%40mail.gmail.com. > > > -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuH5nedq_%3DET84zjz-u%2Bm0sF1JkpvY1ZGdoaqxAB%3D8-qQ%40mail.gmail.com.
[go-nuts] Re: protobuf avoid namespace conflict
So nobody knows how to deal with this? And if some projects have proto files with the same name - protobuf always complain about it? вт, 29 сент. 2020 г. в 10:50, Vasiliy Tolstov : > > Hi! I have two packages server and client. All belongs to different > repos. In this packages i have internal/errors dir with errors.proto > file > Both of them contains go_package option and package unique > > option go_package = "xxx.org/server/internal/errors"; > package server.errors; > > option go_package = "xxx.org/client/internal/errors"; > package client.errors; > > why program that used client and server in the same time have such message > > 2020/09/29 10:50:18 WARNING: proto: file "errors.proto" is already registered > previously from: ""xxx.org/server/internal/errors" > currently from: ""xxx.org/client/internal/errors" > A future release will panic on registration conflicts. See: > https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvaGd8j2MD75EkRvH6zxD89gyKLunxXL6Q5%3DN9VkKWWhQ%40mail.gmail.com.
[go-nuts] protobuf avoid namespace conflict
Hi! I have two packages server and client. All belongs to different repos. In this packages i have internal/errors dir with errors.proto file Both of them contains go_package option and package unique option go_package = "xxx.org/server/internal/errors"; package server.errors; option go_package = "xxx.org/client/internal/errors"; package client.errors; why program that used client and server in the same time have such message 2020/09/29 10:50:18 WARNING: proto: file "errors.proto" is already registered previously from: ""xxx.org/server/internal/errors" currently from: ""xxx.org/client/internal/errors" A future release will panic on registration conflicts. See: https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvUnd_2SY6_cR%3DcqwOeN2x8-Ze6b9vwOK5vv9HZtD%3Dr_Q%40mail.gmail.com.
[go-nuts] add method to interface via reflect
Hi! Does go support adding method to exiting interface via reflect? Mostly I need to add method to struct pointer. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQs62OAkU7OpFpQz9n3zZQPnzrcrAsWtFL78fgjfPv_%3Dkw%40mail.gmail.com.
[go-nuts] go mod why with specific version
Hi! Does go support some magic variant of go mod why but with a specific version? I have some app with multiple external deps and i don't know why some deps required with version from some commit in master branch and not released tag. I'm trying to do go mod vendor and grep whole go.mod files for version , but all files contain lower version of dep. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvjS0ZVsCHtf4efnFqzjoSo%2BWTs--hm5eerhmP_xzTTAQ%40mail.gmail.com.
Re: [go-nuts] CGo-free SQLite database/sql driver for linux/amd64 v1.4.0-beta1 is released
Very cool! Thanks for you great work пн, 27 июл. 2020 г. в 00:01, Jan Mercl <0xj...@gmail.com>: > > (reddit X-post) > > From the change log at https://godoc.org/modernc.org/sqlite#hdr-Changelog > > 2020-07-26 v1.4.0-beta1: > > The project has reached beta status while supporting linux/amd64 only > at the moment. The 'extraquick' Tcl testsuite reports > > 630 errors out of 200177 tests on Linux 64-bit little-endian > > and some memory leaks > > Unfreed memory: 698816 bytes in 322 allocations > > Please try your production load tests and unit tests with the new > version. Your help testing these pre-release versions is invaluable. > > Report any problems using the issue tracker (requires a GitLab > account): > https://gitlab.com/cznic/sqlite/-/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D= > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAA40n-VUH5qDdJW1oVPbbdyuMe%3DH2XOvUFU3tXrsTWMj1RS6sg%40mail.gmail.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsv7RHi2RZ2sWST-Hr%2ByTfyveFOWy3ye4B-ys%3DtELbmsA%40mail.gmail.com.
Re: [go-nuts] Re: golang time.Now().Format with milliseconds without dot in string
пт, 17 июл. 2020 г. в 05:40, Justin Israel : > > > > On Friday, July 17, 2020 at 11:21:32 AM UTC+12 va...@selfip.ru wrote: >> >> вт, 14 июл. 2020 г. в 18:39, Jake Montgomery : >> > >> > I agree, it seems like an unfortunate oversight. You can do it without the >> > slice tricks: https://play.golang.org/p/tNAPOcQqApN >> > It does take an additional Sprintf() though. >> > >> >> Thanks, looks good. But i think for go devs adding additional format >> that can be used to specify milli/micro/nano seconds will be easy. >> >> -- >> Vasiliy Tolstov, >> e-mail: v.to...@selfip.ru > > > I asked the same question on reddit about a month ago, where I needed to > match an existing timestamp format: > https://www.reddit.com/r/golang/comments/gr7hz9/string_formatting_a_timetime_with_custom/ > > Seems string formatting was the best option available to me. > Yes, this is bad case for stuff that works with many messages and want to avoid additional memory allocations -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQtAFAkmr9U2JY14b7Cie2i%2B_w9Oc1d7GiOXgchEaH_bog%40mail.gmail.com.
Re: [go-nuts] Re: golang time.Now().Format with milliseconds without dot in string
вт, 14 июл. 2020 г. в 18:39, Jake Montgomery : > > I agree, it seems like an unfortunate oversight. You can do it without the > slice tricks: https://play.golang.org/p/tNAPOcQqApN > It does take an additional Sprintf() though. > Thanks, looks good. But i think for go devs adding additional format that can be used to specify milli/micro/nano seconds will be easy. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQu97PQt_OZLM8NmAqv998Bi-8N0PzvAQuRsGXDthsuB3Q%40mail.gmail.com.
Re: [go-nuts] Re: golang time.Now().Format with milliseconds without dot in string
вт, 14 июл. 2020 г. в 15:17, Jake Montgomery : > > Why not just remove the dot? You know where it is: > https://play.golang.org/p/ZHqHTOeA7HQ > Perhaps there is a better way, but this seems to work. > Yes, thanks. My question mostly - why format time to some intermediate string that needs to be preprocessed before usage =) Format means that you get a needed sting and not that you must use slice manipulation. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvgos6dd2B-kH-S7JKbDvFU7cVopOZYDAsEQH1TU1av_A%40mail.gmail.com.
[go-nuts] golang time.Now().Format with milliseconds without dot in string
Hi! I'm read several times godoc about the time package but have now way to deal with it. I need to output strings with format MMDDHHMMSSMILLISEC without dot in string. But go able to output milliseconds only in case of .000 -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQthbi9dRiJW38jCPE4PLcjbed5%2BQg5m_qDE2ap2gBXP9w%40mail.gmail.com.
Re: [go-nuts] golang protobuf, struct copy problem
пт, 8 мая 2020 г. в 22:22, Robert Engels : > > Have the compute struct contain the proto struct. > I think that question is more about how to copy fields from one struct to another. For example one struct contains some tags (for example to work with some db orm), and proto struct don't have such tags. > On May 8, 2020, at 1:56 PM, cheng dong wrote: > > > i use protobuf to do rpc in golang . for every message XXX in proto, i have > to define a struct XXX in go, compute and then copy its field one by one to > pb.XXX(because struct XXX have some field not in pb.XXX), when i have many > struct XXX, it is very ineffective and very slow. > > so how could i use a single struct both used for compute and marshal ? > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/f67468e5-cb3b-4026-903a-f7ac49402bbd%40googlegroups.com. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/71BBB1B9-9CDB-4E46-A486-A1FC7BF362BC%40ix.netcom.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsr06xYbv1N1Hg2Ax2KOTPeEa%2BoMowQSVdNOVgYie9kHg%40mail.gmail.com.
[go-nuts] gob or protobuf serialization question
Hi! I have service name it apigw that acts as api gateway. Tha acts as gateway for rest (json) and grpc micro services. I want to able to register some microserver service handler to specific path (for rest json case). But microservice expects to get protobuf message to it handler. So api gw must marshal incoming request from json to protobuf message. Api gw is dedicated service and don't know any protobuf types from other services. I think that if underlying service can send to api gw own struct for specific handler, and api gw can reconstruct this struct from it description to go struct pointer. But as i see gob expects to unmarshal to specific already created value. protobuf have any.Any type that can have TypeUrl. Docs says that this can be remote endpoint that for get request can return binary serialized message for this type. Looks that if i'm transfer serialized protobuf message of needed type with all fields as zero, protobuf must reconstruct proto.Message from it. But cos says that this is not publically available. So my questions: why this is not available and how to deal with my use-case ? Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuB%3DBF0WibSPS_Q%3DYNVVMe80a4VsdJHRAj47QZ6S_pw8Q%40mail.gmail.com.
Re: [go-nuts] how to design log package to avoid allocations
пн, 9 мар. 2020 г. в 19:36, Axel Wagner : > IMO, there really isn't a super good answer. The simple answer is: You > need to delay the actual `fmt.Sprintf` call as long as possible. Which > generally means, that the interface you consume (to allow the user to > direct and configure logging) will need to reflect formatting and all kinds > of things that the user actually doesn't want to deal with. So it's hard to > find a good tradeoff between API simplicity and usability and not > allocating in this case. > > Another, maybe unforseen problem, is that you don't want logging to > interfere with production. It's a painful lesson to learn, that synchronous > logging can take down a production service with ease. If you want to be > prepared for that and reduce the runtime overhead of logging, you will have > to make it asynchronous. But that's fundamentally at odds with the above > goal of delaying formatting - the user will usually not expect arguments to > loggers to be used after the logging call returns. Buffering a formatted > string avoids that of course. > > Thanks! So i think that most simple case is check each time log level , and output log only if level satisfied. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQshiJaz%2BAJ_Tm5VbTW8FDfP0QyLvzj_KCGDTAM7RpiPrg%40mail.gmail.com.
Re: [go-nuts] how to design log package to avoid allocations
пн, 9 мар. 2020 г. в 19:41, andrey mirtchovski : > to avoid allocations you have to hint at the type of what you're going > to print. for example see/use zerolog: https://github.com/rs/zerolog Tanks, I saw it. But mostly i want to avoid typing hint -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuANkcEisvyh3ad3s%2B0MP1dpR9vaoh7-CTjWF_G5SOYCA%40mail.gmail.com.
[go-nuts] how to design log package to avoid allocations
Hi! I have some logging package and after memory profiling saw that for disabled log levels i'm allocate memory for message. For example i'm send in logger only Info level. So i want to avoid Debug/Trace stuff. but memory profiling says that for call log.Tracef("my message %v", msg) i'm allocate memory. I don't want to guard all calls to check enabled log level to avoid allocation. How can i do zero allocation log in such case? Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQswqK3DGHESCFd4pCdxndFpOFyKXhO25UDKgEsxYeK3SA%40mail.gmail.com.
[go-nuts] forbid downloading package without go.mod enabling
I'm work on go-micro project and usually users try to use package inside GOPATH or without go module on. This breaks things, and users asks on github issue that nothing works. Is it possible to disallow getting package without go modules enabled? Or what is the best practice for this (mentioned in readme go module usage not helps). -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQudO_AxNhZZTS7hnuYSn_0AnkD%3DxZpcYf203puByQtKBg%40mail.gmail.com.
[go-nuts] Re: run tests for all sub modules
So this is impossible with per package modules in one repo? вс, 19 янв. 2020 г. в 02:39, Vasiliy Tolstov : > > Hi! I have one repo with multiple packages. For each package i have > dedicated go.mod (this is a requirement because repo is collection of > plugins with many deps). > How to run test for all of them? go test ./... does not run tests for > sub modules. Now i have very ugly thing: > find . -name 'go.mod' , collect all dirs and run go test for all of > them. Is it possible to have something less ugly? > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsJMjte%2Bh0D7hDZ2CNajUz3FDJVp5BPd81K4wFtRZH%3DdA%40mail.gmail.com.
[go-nuts] run tests for all sub modules
Hi! I have one repo with multiple packages. For each package i have dedicated go.mod (this is a requirement because repo is collection of plugins with many deps). How to run test for all of them? go test ./... does not run tests for sub modules. Now i have very ugly thing: find . -name 'go.mod' , collect all dirs and run go test for all of them. Is it possible to have something less ugly? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsiBs1H5rQyvxv%2BA3MrNDDbRsqGvmabco6w8UOqcZdJsg%40mail.gmail.com.
Re: [go-nuts] Re: help with reflect
вт, 10 дек. 2019 г. в 00:49, Dan Kortschak : > > On Mon, 2019-12-09 at 14:57 +0300, Vasiliy Tolstov wrote: > > Nevermind. I found the error > > https://paulcunningham.me/nevermind-found-answer/ > Ok, sorry, i'm try to provide answer for next time =) -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQu5jYQxyKmHk9SK-Y4qmOqyg2icQ%3Di0i7yaGk8%2BXFnWbA%40mail.gmail.com.
Re: [go-nuts] Announcing sqlc: Compile SQL queries to type-safe Go
Thanks! But how about real world cases like joining 5 tables and using having and other stuff? ср, 11 дек. 2019 г. в 22:48, : > > Hey gophers, > > I'm excited to announce sqlc, my project for turning SQL into type-safe Go. > With sqlc, the following SQL: > > > CREATE TABLE authors ( > id BIGSERIAL PRIMARY KEY, > name text NOT NULL, bio text > ); > > > -- name: GetAuthor :one > SELECT * FROM authors WHERE id = $1 LIMIT 1; > > gets turned into this Go > > package db > > import ( > "context" > "database/sql" > ) > > type Author struct { > ID int64 > Name string > Bio sql.NullString > } > > const getAuthor = `-- name: GetAuthor :one > SELECT id, name, bio FROM authors > WHERE id = $1 LIMIT 1 > ` > > type Queries struct { > db *sql.DB > } > > func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) { > row := q.db.QueryRowContext(ctx, getAuthor, id) > var i Author > err := row.Scan(&i.ID, &i.Name, &i.Bio) > return i, err > } > > I wrote up a larger piece about why I started the project here: > https://conroy.org/introducing-sqlc. It includes a guided walk through and > more example code. > > Happy to answer any questions you have about the project. > > Cheers, > Kyle > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/2d87986d-fc00-4fc2-afa3-352dedc2f9b7%40googlegroups.com. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvLauLKiR1NqShYGNRGxztcqN0dfLoQCGxWVdqcXx%2BTqA%40mail.gmail.com.
[go-nuts] Re: help with reflect
Nevermind. I found the error пн, 9 дек. 2019 г. в 12:30, Vasiliy Tolstov : > > Hi! I'm stuck at reflection based struct assignment. > > example struct > type TestStruct struct { > Slice []*string > } > > func TestReflect(t *testing.T) { > s1 := "one" > s2 := "two" > s1 := "one" > s2 := "two" > nodes := []*string{&s1, &s2} > v := &TestStruct{} > valueOf := reflectValue(v) > typeOf := reflectType(v) > > for i := 0; i < valueOf.NumField(); i++ { > field := valueOf.Field(i) > sfield := typeOf.Field(i) > > slice := reflect.MakeSlice(sfield.Type, 0, 0) > > log.Printf("field %v\n", field) > log.Printf("sfield %v\n", sfield) > log.Printf("slice %v\n", slice) > > for _, node := range nodes { > log.Printf("sfield elem %v\n", sfield.Type.Elem()) > value := reflect.New(sfield.Type.Elem()) > setVal := reflect.ValueOf(node) > log.Printf("value %v\n", value) > value.Set(setVal) > } > } > > but i'm have error > panic: reflect: reflect.flag.mustBeAssignable using unaddressable > value [recovered] > panic: reflect: reflect.flag.mustBeAssignable using unaddressable > value > > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQtAa2ncNSk0b3cLO6S1OYBbEbH9%2BnxZM1FnH65mFOtcAA%40mail.gmail.com.
[go-nuts] Re: help with reflect
Mainly i have bigger requirement: type TestStruct struct { Slice []*TestItem } type TestItem struct { Value1 string Value2 string } so i need to create slice via reflect in TestStruct variable, create variable for TestItem and iterate over TestItem fields and assign to it Value1 and Value2 some text after some changes i have reflect: call of reflect.Value.NumField on ptr Value so reflect.New(sfield.Type.Elem()).Elem() returns pointer to needed struct, but if i'm use reflect.Indirect i have nil variable and can't do NumField on it пн, 9 дек. 2019 г. в 12:30, Vasiliy Tolstov : > > Hi! I'm stuck at reflection based struct assignment. > > example struct > type TestStruct struct { > Slice []*string > } > > func TestReflect(t *testing.T) { > s1 := "one" > s2 := "two" > s1 := "one" > s2 := "two" > nodes := []*string{&s1, &s2} > v := &TestStruct{} > valueOf := reflectValue(v) > typeOf := reflectType(v) > > for i := 0; i < valueOf.NumField(); i++ { > field := valueOf.Field(i) > sfield := typeOf.Field(i) > > slice := reflect.MakeSlice(sfield.Type, 0, 0) > > log.Printf("field %v\n", field) > log.Printf("sfield %v\n", sfield) > log.Printf("slice %v\n", slice) > > for _, node := range nodes { > log.Printf("sfield elem %v\n", sfield.Type.Elem()) > value := reflect.New(sfield.Type.Elem()) > setVal := reflect.ValueOf(node) > log.Printf("value %v\n", value) > value.Set(setVal) > } > } > > but i'm have error > panic: reflect: reflect.flag.mustBeAssignable using unaddressable > value [recovered] > panic: reflect: reflect.flag.mustBeAssignable using unaddressable > value > > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsKQx4PfYqga8vtyKpKXKVMTR3y3Zt9VReD4Op9nsFmoQ%40mail.gmail.com.
[go-nuts] help with reflect
Hi! I'm stuck at reflection based struct assignment. example struct type TestStruct struct { Slice []*string } func TestReflect(t *testing.T) { s1 := "one" s2 := "two" s1 := "one" s2 := "two" nodes := []*string{&s1, &s2} v := &TestStruct{} valueOf := reflectValue(v) typeOf := reflectType(v) for i := 0; i < valueOf.NumField(); i++ { field := valueOf.Field(i) sfield := typeOf.Field(i) slice := reflect.MakeSlice(sfield.Type, 0, 0) log.Printf("field %v\n", field) log.Printf("sfield %v\n", sfield) log.Printf("slice %v\n", slice) for _, node := range nodes { log.Printf("sfield elem %v\n", sfield.Type.Elem()) value := reflect.New(sfield.Type.Elem()) setVal := reflect.ValueOf(node) log.Printf("value %v\n", value) value.Set(setVal) } } but i'm have error panic: reflect: reflect.flag.mustBeAssignable using unaddressable value [recovered] panic: reflect: reflect.flag.mustBeAssignable using unaddressable value -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuwv2Pqjm_sN3n0y9CNMo8VbfWfWid0kdbE_QoA3gwBXA%40mail.gmail.com.
[go-nuts] transparent mitmproxy with cert caching
Hi!. I found many mitmproxy tools in go, but can't find any that able to cache generated certificates. I think that this is saves compute time. Also i want to modify it to work with uBlock to deny unneeded requests. Do you know anything about this? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQskjpbtiOcHLB9aQAVBG2MiD5FYqDRT8hS-cd9%2B2n0bbw%40mail.gmail.com.
Re: [go-nuts] Get struct type , save and reconstruct empty struct later
сб, 20 июл. 2019 г. в 17:17, Martin Schnabel : > > If you only need any unnamed struct type you can create one with reflect > from the field information that you can write to text somewhere. > > https://godoc.org/reflect#StructOf > > These unnamed struct types however do not have any methods and do not > wrap embedded named type methods. > > Otherwise you probably want to register your struct types on program > initialization; for later lookup and so that they are part of the > compiled binary. The gob package does it like that for example. > Thanks for link doc. It is very useful. Now i think that i'm try to use protobuf Any (as all of my struct are protobuf proto.Message. As i understand via protobuf i can register needed Req/Rsp empty messages via Any, and later unmarshal message to this empty structs. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQtV_4DYtGpMZULc4TMEr8uTUZ2PaLbUHz54i2%3DnD6XVBw%40mail.gmail.com.
Re: [go-nuts] Get struct type , save and reconstruct empty struct later
Thanks, something like this, but i need to store type in string or []byte in db, and based on this create new empty struct. сб, 20 июл. 2019 г., 10:55 Jan Mercl <0xj...@gmail.com>: > On Sat, Jul 20, 2019 at 9:28 AM Vasiliy Tolstov > wrote: > > > Hi. I have reflection based question. > > I need to store type of struct passed to func and later based on this > stored type reconstruct empty needed struct. > > Does this possible ? > > Not sure I understood the question: https://play.golang.org/p/5AEn3IsKObo > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQsO90D5iDOZEpsgwbPBgEu%3DU8eLpYeg%3D2b2odAcp55f9g%40mail.gmail.com.
[go-nuts] Get struct type , save and reconstruct empty struct later
Hi. I have reflection based question. I need to store type of struct passed to func and later based on this stored type reconstruct empty needed struct. Does this possible ? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQuvs1Ytv_67LUov420j-Aic2MtycS8BMC4HZ_kwNB%3DmAg%40mail.gmail.com.
Re: [go-nuts] listen port auto allocation questions
вс, 14 июл. 2019 г. в 00:30, Andrew Pillar : > > > How can i'm avoid such errors and not specify ports by hand? > Perhaps you could use some kind of central store for storing the most > recently used port? Simply take that port from the store, increment it, > and place it back into the store for the next micro-service to use. > > I think etcd [1], may be a good use case for this. I think about it, but then we pass to kernel port 0, it allocates free port, but this is not mean that after millisecond this port not be used by other service -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvW0tRoMEP1wfTOZPeC-3aNw25kd2Tgf0j5fq7Ys%2BAEqw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] listen port auto allocation questions
Hi. I have busy system with more then 2 ports in use. I need to run 20-50 microservices and each of them need to listen tcp port. I want to use listen port auto allocation by specify as listen port :0 Sometimes i have errors like already listening on []:22925 that happened because port already in use when start by other service. How can i'm avoid such errors and not specify ports by hand? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQvpiW14CCuxjx7%3DAMEFip-rQ7Pw1cOTDiENu_XqU_BWHg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] get interface and method name
чт, 11 июл. 2019 г. в 00:27, Ian Lance Taylor : > > On Wed, Jul 10, 2019 at 1:40 PM Vasiliy Tolstov wrote: > > > > Hi! i have interface like > > > > type AccountService interface { > > Create(context.Context) error > > } > > > > if i need to get string representation of this interface from passed > > AccountService.Create how can i do that? > > > > Now i create POC like this: > > parts := > > strings.Split(runtime.FuncForPC(reflect.ValueOf(iface).Pointer()).Name(), > > ".") > > return parts[len(parts)-2] + "." + parts[len(parts)-1] > > > > it returns string "AccountService.Create" > > Does it possible to get this not using runtime? only via reflect and > > may be without strings ? > > Can you show us a working example in the Go playground to demonstrated > what you are looking for? > > If your interface is named AccountService, I would not expect any > method to be named AccountService.Create. The Create method will be > defined on other types converted to the interface type, not on the > interface type itself. So I'm not sure what you are actually looking > for. > > Ian https://play.golang.org/p/VZhO4KdKk-J I need to return textual representation of interface name and method name. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQs-Ag8Pxg9pdgNNev3M%2BAuTV-LPdM9%2B6Q4w2C8acjLgJQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] get interface and method name
Hi! i have interface like type AccountService interface { Create(context.Context) error } if i need to get string representation of this interface from passed AccountService.Create how can i do that? Now i create POC like this: parts := strings.Split(runtime.FuncForPC(reflect.ValueOf(iface).Pointer()).Name(), ".") return parts[len(parts)-2] + "." + parts[len(parts)-1] it returns string "AccountService.Create" Does it possible to get this not using runtime? only via reflect and may be without strings ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQt7QsQQSZ-tn2p8nyGL3XWdZm0ruTHu_-3-iL5P0gQOww%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: net.InterfaceAddrs() error and returned addr slice
чт, 16 мая 2019 г. в 19:04, : > > > > On Wednesday, May 15, 2019 at 5:00:26 PM UTC-4, Vasiliy Tolstov wrote: >> >> Hi! I have error from net.InterfaceAddrs() like route ip+net: no such >> network interface >> i think that error happened because i have docker running that >> creates/deletes interfaces in my system. >> My question is - does returned slice from InterfaceAddrs filed always, >> or in case of error in always nil? As i understand go uses netlink to >> get all interfaces and when tries to get address from interface that >> already gone, this error happened. >> In my case this error not fatal, i only need to know all local unicast >> addresses. So if some interface is gone - this is not fatal, but i >> need to get all available ip. >> So if this function not fills the slice , i need to use different >> method to get all addresses. >> >> Can you helps me? >> P.S. Error not easy to reproduce in my case, so i can't easy check >> does InterfaceAddrs slice filled in case of error. >> > > > In Go it is customary that nothing should be assumed about the other return > values when there is an error. Since the InterfaceAddrs documentation does > not specify what the Addr slice contains on error, you should make no > assumptions. > > That said, looking at the code, it looks like most or all of the error paths > will return a nil slice. > > However, the InterfaceAddrs documentation does suggest an alternative. It > says: "use Interfaces and Interface.Addrs for more detail." So you could try > using that, and ignore any interfaces that return an error. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/c8580226-56ba-4647-b4d2-4948498f9755%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. Yes, thanks. This helps me. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQtpgo5o4wGmzMg18E%2BXRWPBs2M3n6W-7DOMdDjUyJxvTQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] net.InterfaceAddrs() error and returned addr slice
Hi! I have error from net.InterfaceAddrs() like route ip+net: no such network interface i think that error happened because i have docker running that creates/deletes interfaces in my system. My question is - does returned slice from InterfaceAddrs filed always, or in case of error in always nil? As i understand go uses netlink to get all interfaces and when tries to get address from interface that already gone, this error happened. In my case this error not fatal, i only need to know all local unicast addresses. So if some interface is gone - this is not fatal, but i need to get all available ip. So if this function not fills the slice , i need to use different method to get all addresses. Can you helps me? P.S. Error not easy to reproduce in my case, so i can't easy check does InterfaceAddrs slice filled in case of error. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQt6P%3DgsQ_%2B2mgsJ-%3Dayxv3Gh-AbkpF_J4N4o4wziK5K8w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: Get fingerprint of ca
вт, 30 апр. 2019 г. в 23:30, Marcin Romaszewicz : > > Now we're onto the topic of TLS chain of trust. The full answer is > complicated. > > In your case, I think the answer is Yes. > > Say you have RootCA which signs SubCA which signs ServerCert. > > When your server serves on the internet, it can present just ServerCert to > the clients, and if the clients know (SubCa, RootCA), then the server doesn't > need to present them. If the clients only trust (RootCA), then the server > would have to present (ServerCA, SubCA) to the clients in order to build the > chain of trust. All the certificates involved in a connection must be > presented, but where you stop checking the chain is up to you. > > Have a look here as starting points. > https://ericchiang.github.io/post/go-tls/ > https://security.stackexchange.com/questions/130847/how-tls-certificate-chain-is-verified > > Thank you for help. Now i think that i have all needed pieces and next steps is to write simple code that acts like i need =) -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: Get fingerprint of ca
вт, 30 апр. 2019 г. в 23:01, Marcin Romaszewicz : > > Look at the ""crypto/x509" package, specifically at CertPool. You would load > your CA public cert and intermediate cert's into a CertPool. > > Once you have a CertPool, you can use it in tls.Config to configure your TLS > connections. Given a valid certificate chain, Go will automatically validate > server TLS certificates. If you want client cert validation, you have to > enable it (https://golang.org/src/crypto/tls/common.go?s=8208:8231#L227) > > Is that what you were looking for? > Thanks looks fine, but does i need to always have root ca to trust intermediate certs? Or if i have custom validation in tls.Config i don't need it? For example i'm pass root ca fingerprint to service, does it possible to trust all intermediates if they issued by root CA that have the same fingerprint ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: Get fingerprint of ca
вт, 30 апр. 2019 г. в 16:23, : > > > If I'm understanding your question correctly, this Youtube video from the > 2018 Gophercon should help: https://www.youtube.com/watch?v=kxKLYDLzuHA > Thanks, i'm already saw this. My question about ability to get trust root self signed CA cert, and trust all intermediate cert from it. Also trust all client certs from it intermediates. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Get fingerprint of ca
Also if i use own root ca to issue intermediate cert that used for issue client certs. How can i check that intermediate ca is issued by root ca? вт, 30 апр. 2019 г., 10:48 Vasiliy Tolstov : > Hi! May be i miss something, how can i get ca cert fingerprint in go via > builtin packages if i have client cert issued via this ca? > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Get fingerprint of ca
Hi! May be i miss something, how can i get ca cert fingerprint in go via builtin packages if i have client cert issued via this ca? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: Mutual tls example
пн, 22 апр. 2019 г. в 20:06, Timothy Raymond : > > I believe Liz Rice covered this in her GopherCon 2018 talk on TLS > connections: https://www.youtube.com/watch?v=kxKLYDLzuHA > Thank you this is very helpful for me. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Mutual tls example
Thank you, may be i find mode detailed example https://diogomonica.com/2017/01/11/hitless-tls-certificate-rotation-in-go/amp/ вс, 21 апр. 2019 г. в 15:22, Aldrin Leal : > > I did a while ago, but I can't share a sample. But you can build one, > provided that: > > 1. build your server as such (note the ClientAuth - thats where magic > happens): > > ... > rootCAs, _ := x509.SystemCertPool() > > if nil == rootCAs { > rootCAs = x509.NewCertPool() > } > > cfg := &tls.Config{ > MinVersion: tls.VersionSSL30, > /* > CurvePreferences: > []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, > PreferServerCipherSuites: true, > CipherSuites: []uint16{ > tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, > tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, > tls.TLS_RSA_WITH_AES_256_GCM_SHA384, > tls.TLS_RSA_WITH_AES_256_CBC_SHA, > }, > */ > ClientAuth: tls.VerifyClientCertIfGiven, > RootCAs:rootCAs, > } > > cert, err := tls.LoadX509KeyPair(*publicCertificate, *privateKey) > > ... > > > > srv := &http.Server{ > Addr: ":8043", > Handler: > handlers.RecoveryHandler(handlers.PrintRecoveryStack(true))(r), > TLSConfig:cfg, > TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, > http.Handler), 0), > } > > log.Fatal(srv.ListenAndServeTLS(*publicCertificate, *privateKey)) > > > 2. Look into http.Request, under TLS.PeerCertificates array > -- > -- Aldrin Leal, / https://ingenieux.io/about/ > > > On Sun, Apr 21, 2019 at 7:09 AM Vasiliy Tolstov wrote: >> >> Hi, I'm try to find mutual tls example in go, but can't find simple example >> that uses crypto/tls. I need server that for some http handler for user >> request with token returns tls cert for communication, and client that uses >> this cert to communication after it returned from request. Ideally with >> ability to rotate keys on client before previous expired. >> Does anybody knows it? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Mutual tls example
Hi, I'm try to find mutual tls example in go, but can't find simple example that uses crypto/tls. I need server that for some http handler for user request with token returns tls cert for communication, and client that uses this cert to communication after it returned from request. Ideally with ability to rotate keys on client before previous expired. Does anybody knows it? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: bin packing or knapsack
Thanks, Jason! вс, 16 дек. 2018 г. в 06:00, Jason E. Aten : > > search for branch-and-bound; e.g. > https://www.geeksforgeeks.org/0-1-knapsack-using-branch-and-bound/ > > On Saturday, December 15, 2018 at 5:01:51 PM UTC-6, Vasiliy Tolstov wrote: >> >> Hi! i have task that have some resource constrains for example: >> Cpu Count >> Memory size >> Disk Size >> >> And have some servers, so i need optimal put this tasks on this >> servers (tightly) >> What is optimal algo for this case? As i see i need 3 dimensions, but >> i can't rotate items. Where i can read more info about solving bin >> packing/knapsack for such cases? >> Thanks! >> >> -- >> Vasiliy Tolstov, >> e-mail: v.to...@selfip.ru > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] bin packing or knapsack
Hi! i have task that have some resource constrains for example: Cpu Count Memory size Disk Size And have some servers, so i need optimal put this tasks on this servers (tightly) What is optimal algo for this case? As i see i need 3 dimensions, but i can't rotate items. Where i can read more info about solving bin packing/knapsack for such cases? Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Load balancing based on task memory and cpu requirement
Hi all. I have bunch of tasks that have predictable memory and cpu usage. I need to run them on some nodes in optimal case - fillup one node by one. Some task not needs to be run on the same node. Does anybody knows package that already provide ability to select nodes with this requirements? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Q16.16 fixed point numbers in go
ср, 24 окт. 2018 г. в 19:52, Michael Jones : > > https://en.wikipedia.org/wiki/Q_(number_format) says it all. > > you can use fixed point all the way...just shift after multiplies and before > divides and use double-width (int32) or wider math. > Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] microservices framework
вт, 23 окт. 2018 г. в 20:23, Marko Ristin-Kaufmann : > > Hi Vasiliy, > We use our own swagger-to code generator for external communication and > zeromq & protobufs for internal components. > > We foung the code generated by go-swagger to be a bit too complex. > > Swagger-to: https://github.com/Parquery/swagger-to > > Cheers Marko > > Le mar. 23 oct. 2018 à 19:02, Vasiliy Tolstov a écrit : >> >> Hi! I'm looking for new project some framework to write microservice based >> app. >> I'm found micro and go-kit. But micro have needed features only in >> enterprise version (i'm need mit / bsd license) , go-kit for simple >> service need to big code (now i'm using grpc-gateway and grpc based >> services) and as i see examples - sometimes compilcated. >> >> Does anybody knows alternatives? >> Problem not in swagger spec, but now to write discovery / transport by hands, but saves time for development. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] microservices framework
Hi! I'm looking for new project some framework to write microservice based app. I'm found micro and go-kit. But micro have needed features only in enterprise version (i'm need mit / bsd license) , go-kit for simple service need to big code (now i'm using grpc-gateway and grpc based services) and as i see examples - sometimes compilcated. Does anybody knows alternatives? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Q16.16 fixed point numbers in go
Thanks for suggestions. If somebody can look at github.com/unistack-org/go-crush package (ported ceph crush to go) i'l be happy. Now weight represented as float32, i'm try to use https://github.com/shopspring/decimal but code looks ugly with many conversations. And also as i see ceph code (mapper.c for crush) they does not use something different for weights but uint32. may be i miss something but i don't understand how they deal with weights like 0.580 in such cases. So if somebody wants to help - i'l be happy. пн, 22 окт. 2018 г. в 17:14, 'Ingo Oeser' via golang-nuts : > > https://godoc.org/golang.org/x/image/math/fixed might provide some hints how > to work with this kind of type. > > The idea is to use a special type and provide all operations you need. > > https://godoc.org/math/big#Rat might be helpful to create first tests of the > basic math operations with maximum precision, before reducing precision with > a conversion to a more limited data type. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Q16.16 fixed point numbers in go
Does it possible to avoid conversation and works only with fixed point (if this can bring performance speedup)? пн, 22 окт. 2018 г. в 16:13, Vasiliy Tolstov : > > пн, 22 окт. 2018 г. в 16:02, Jan Mercl <0xj...@gmail.com>: > > > > On Mon, Oct 22, 2018 at 2:35 PM Vasiliy Tolstov wrote: > > > > > Does reading this 4 bytes to uint32 and use math.Float32frombits looks > > > right? > > > > It does not look right, see > > https://en.wikipedia.org/wiki/Q_(number_format)#Q_to_float > > > Thanks, so i need to read uint16 Num and uint16 Exp? > After that use number Num*2−exp ? > > -- > Vasiliy Tolstov, > e-mail: v.tols...@selfip.ru -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Q16.16 fixed point numbers in go
пн, 22 окт. 2018 г. в 16:02, Jan Mercl <0xj...@gmail.com>: > > On Mon, Oct 22, 2018 at 2:35 PM Vasiliy Tolstov wrote: > > > Does reading this 4 bytes to uint32 and use math.Float32frombits looks > > right? > > It does not look right, see > https://en.wikipedia.org/wiki/Q_(number_format)#Q_to_float Thanks, so i need to read uint16 Num and uint16 Exp? After that use number Num*2−exp ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Q16.16 fixed point numbers in go
Hi! I have some binary format that contains in 4 bytes Q16.16 fixed point number in LittleEndian. Does reading this 4 bytes to uint32 and use math.Float32frombits looks right? And also as i understand if in my code i use float32 i have performance decrease vs if i work with fixed point int? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: splitting package question
As i test go compiler remove unused functions (i'm not try to check compile time, but resulted binary size not changed after i merge all formats in single package). сб, 6 окт. 2018 г. в 19:31, T L : > > You can make some tests to check the final binary sizes, which will not spend > you much time. :) > > The official linker does try to remove many unused functions. > Unused functions really need more time to compile. > > On Saturday, October 6, 2018 at 10:08:43 AM UTC-4, Vasiliy Tolstov wrote: >> >> Hi! >> I have some data that can be formatted with json, text and binary form. >> Does i need to split this on three parts (json, text, binary) to avoid >> compile time and run time overhead (and disk size of resulted binary) >> if user want to use only one format (for example binary). Or go >> compiler remove unused functions and not include them in resulted >> binary? (if i don't use json Marshal/Unmarshal full json package not >> included in my binary) >> Thanks! >> >> -- >> Vasiliy Tolstov, >> e-mail: v.to...@selfip.ru > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] splitting package question
Hi! I have some data that can be formatted with json, text and binary form. Does i need to split this on three parts (json, text, binary) to avoid compile time and run time overhead (and disk size of resulted binary) if user want to use only one format (for example binary). Or go compiler remove unused functions and not include them in resulted binary? (if i don't use json Marshal/Unmarshal full json package not included in my binary) Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] implement something like writeback journal for writing files
2017-12-25 19:50 GMT+03:00 Tamás Gulácsi : > Butthat package seems to be a perfect fit. > Create a wal only for writers. I have virtual disk that provided for client, disk represented by 4Mb blocks, when user writes data inside vm, data written to specific block at specific offset. In this case i need wal for all blocks in current server. In case of 5gb disk i have 1255 files (because some files replicated across hdd in single server via ketama hash ring. And cache fd not very usable, because i think that that after write and before flush from ssd to hdd i read at mostly one time. > You'll have to cache the file descriptors anyway. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] implement something like writeback journal for writing files
25 Дек 2017 г. 13:54 пользователь "Jan Mercl" <0xj...@gmail.com> написал: On Mon, Dec 25, 2017 at 10:11 AM Vasiliy Tolstov wrote: What about a write ahead log? https://godoc.org/github.com/cznic/file#WAL I know about this package, but I have many files like 3-5 and create Wal for each file is overhead... -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] implement something like writeback journal for writing files
Hi. I have some servers with sata hdd and 2 ssd. I want to use ssd for writeback journal to provide faster speed in case of writing and not lost durability. Client connects to server and send some chunk of data with file name and offset. As of sata hdd is slow, i want to write data chunks to journal and with additional thread flush to disks. Main problems: client can send write requests to single file but different offsets client can send read request after/before write and sometimes client try to read data that presented only in journal. And sometimes client can read data with len bigger when written before (so i need to read some data from journal and some from hdd) I'm try to check ceph journal format on disk layout http://irq0.org/articles/ceph/journal but don't understand how it helps with read data after write. Also i'm try to read jbd2 code from linux kernel, but have no luck =(. I know about bcache, lvm cache, flashcache and other solutions, but i need pure go and pure application solution. Does somebody already thinks about such problems or know some link where i can find ideas? Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: Why is the cpu usage so high in a golang tcp server?
If I have something like this, but I know that client sends fixed sized message header 48 byte and variable sized body based on data in header, and want to minimize allocations. Does I need to use bufio? Now I'm use goleveldb util package for reusable byte slice. 19 Дек 2017 г. 11:22 пользователь "Dan Kortschak" < dan.kortsc...@adelaide.edu.au> написал: > bufio.NewReader > > On Mon, 2017-12-18 at 05:11 -0800, Tamás Gulácsi wrote: > > > n, err := sock.Read(buf) > > > > > > > > This will be slow: TCP is a streaming protocol, so this Read can read > > any > > length between 0 (! yes !) and 1024 bytes. > > Use buffering (bytes.NewReader) and some kind of message separation > > (e.g. > > bufio.Scanner for a line-oriented protocol). > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] cache for *os.File
2017-12-14 9:28 GMT+03:00 Dave Cheney : > Does your profiling suggest these allocations are causing latency? > Hmm this is missing part =). How can i understand what causing latency if i use http prof? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] cache for *os.File
2017-12-13 22:31 GMT+03:00 Dave Cheney : > What does profiling say? Does your program spend the majority of its time > stating files? Do stats add a significant amount of latency to your > request/response cycle? > In my case profiling says only about memory allocations when i'm do os.OpenFile because passed path copied to file struct. Does it possible to eliminate such allocations? In my program i don't often do stat syscalls. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] cache for *os.File
Hi! I'm not test my question, but may be somebody already knows. Nginx for example have fd cache mostly i think for sendfile syscall , so nginx already knows that file exists and it size that needed for sendfile. If i write server what accept requests from clients and read/write to many files on local fs, sometimes with different offsets. Does i need fd cache for such use-case? Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] package for concurrent os.File operations
I have []*os.File that need to be Write/Close/Sync/Seek concurrent with proper return values (so if one Write return error i need to catch it ad return to upper layer. In case Seek i need to check that all Seeks returns equal values without errors. Ideally that []*os.File is wrapped to interface that can be read/write/close/seek/sync... Does somebody already knows such package or knows how to best write it ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: try to avoid additional memory allocations
Thanks, i know that optimization can lead obscurity, but for critical paths i think that it useful =) 2017-11-10 8:41 GMT+03:00 peterGo : > Vasiliy, > > For portability, when you initialize cfg.WorkDir, clean it: cfg.WorkDir = > filepath.Clean(cfg.WorkDir) > > You can reduce the allocations from 5 to 1. However, optimization can lead > to obscurity. For example, > > $ go test oid_test.go -bench=. > BenchmarkVasiliy-4 200700 ns/op88 B/op5 allocs/op > BenchmarkKrolaw-4 300550 ns/op80 B/op4 allocs/op > BenchmarkPeter-4 1000201 ns/op48 B/op1 allocs/op > > Playground: https://play.golang.org/p/DnGoM8PYd6 > > Peter > > > On Thursday, November 9, 2017 at 3:58:03 PM UTC-5, Vasiliy Tolstov wrote: >> >> Hi. I have server that read/write data to many files (each is about >> 4-32Mb). To determine on which file i need to read/write i'm use this >> function to os.OpenFile >> >> func oid2filepath(cfg *Config, oID uint64) string { >> file_path := filepath.Join(cfg.WorkDir, fmt.Sprintf("%x", >> oid2vid(oID)), fmt.Sprintf("%016x", oID)) >> return file_path >> } >> >> oid2vid function get uint32 and return uint32 with shift some bits >> path looks like (for one of 4Mb chunk) store/obj/7c2b25/007c2b250180 >> >> When i'm write 4Gb data i need to call this function 1024 times for >> single big chunk of data. >> Does it possible to write function that does not have additional >> allocations? >> And does it possible to write it in portable way (i mean path separator). >> >> >> -- >> Vasiliy Tolstov, >> e-mail: v.to...@selfip.ru > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: try to avoid additional memory allocations
Thanks! 2017-11-10 3:52 GMT+03:00 krolaw : > func oid2filepath(cfg *Config, oID uint64) string { >return fmt.Sprintf("%s%c%x%c%016x", cfg.WorkDir, filepath.Seperator, > oid2vid(oID), filepath.Seperator, oID) > } > > On Friday, 10 November 2017 09:58:03 UTC+13, Vasiliy Tolstov wrote: >> >> Hi. I have server that read/write data to many files (each is about >> 4-32Mb). To determine on which file i need to read/write i'm use this >> function to os.OpenFile >> >> func oid2filepath(cfg *Config, oID uint64) string { >> file_path := filepath.Join(cfg.WorkDir, fmt.Sprintf("%x", >> oid2vid(oID)), fmt.Sprintf("%016x", oID)) >> return file_path >> } >> >> oid2vid function get uint32 and return uint32 with shift some bits >> path looks like (for one of 4Mb chunk) store/obj/7c2b25/007c2b250180 >> >> When i'm write 4Gb data i need to call this function 1024 times for >> single big chunk of data. >> Does it possible to write function that does not have additional >> allocations? >> And does it possible to write it in portable way (i mean path separator). >> >> >> -- >> Vasiliy Tolstov, >> e-mail: v.to...@selfip.ru > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] try to avoid additional memory allocations
Hi. I have server that read/write data to many files (each is about 4-32Mb). To determine on which file i need to read/write i'm use this function to os.OpenFile func oid2filepath(cfg *Config, oID uint64) string { file_path := filepath.Join(cfg.WorkDir, fmt.Sprintf("%x", oid2vid(oID)), fmt.Sprintf("%016x", oID)) return file_path } oid2vid function get uint32 and return uint32 with shift some bits path looks like (for one of 4Mb chunk) store/obj/7c2b25/007c2b250180 When i'm write 4Gb data i need to call this function 1024 times for single big chunk of data. Does it possible to write function that does not have additional allocations? And does it possible to write it in portable way (i mean path separator). -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] graceful restart of app with more than one tcp Listener
2017-11-07 17:20 GMT+03:00 Steven Hartland : > There are a number of libraries which attempt to address this, ones I've > seen: > > https://github.com/fvbock/endless > https://github.com/rcrowley/goagain > https://github.com/facebookgo/grace > > I know about it, but https://github.com/rcrowley/goagain/issues/12 cant handle multiple listeners https://godoc.org/github.com/facebookgo/grace/gracenet does not support close the listener https://github.com/fvbock/endless works with http , but i don't need http server. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] graceful restart of app with more than one tcp Listener
Hi! I have application that listens 2-4 tcp ports and i need to upgrade it while running. How can upgrade server and not dropping exiting connected apps (tcp nbd-client like apps)? I don't want to use haproxy or nginx before my app. As i understand i need master process that only listens sockets and fork child app and pass to it accepted connections. So i can upgrade by passing listening fd to new master process and forward new tcp connections to new child? But what can i do with already connected clients to previous child process? Does it possible to do what i need and not dropping exiting tcp connections? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: speedup image/png encode/decode
2017-06-18 19:47 GMT+03:00 Vasiliy Tolstov : > Hi. I'm writing vnc server implementation (mostly for proxy between > client and real server). > My first version can only raw encoding, but now i'm writing TightPng > support and check results. As i see when i'm connect to my proxy from > noVNC (that supports TightPng encoding), my proxy use 400-500% CPU > (Intel Xeon E5620). > > Main parts is > https://github.com/vtolstov/go-vnc/blob/master/encoding.go#L238 for read > https://github.com/vtolstov/go-vnc/blob/master/encoding.go#L193 for write > > What i miss and what i can change to speedup encode/decode and > minimize CPU usage? > P.S. I'm not try to profile code, may be is have many big errors that > can be solved firstly... profile available via http http://185.147.83.147:6060/debug/pprof/profile -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] speedup image/png encode/decode
Hi. I'm writing vnc server implementation (mostly for proxy between client and real server). My first version can only raw encoding, but now i'm writing TightPng support and check results. As i see when i'm connect to my proxy from noVNC (that supports TightPng encoding), my proxy use 400-500% CPU (Intel Xeon E5620). Main parts is https://github.com/vtolstov/go-vnc/blob/master/encoding.go#L238 for read https://github.com/vtolstov/go-vnc/blob/master/encoding.go#L193 for write What i miss and what i can change to speedup encode/decode and minimize CPU usage? P.S. I'm not try to profile code, may be is have many big errors that can be solved firstly... -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] terminal package that utilize io.ReadWriter
I have some ReadWriter stream interface, that utilize custom rpc to send/recv data from/to endpoint. I need terminal package to run on client that understand standard terminal escape symbols and can be used with ReadWriter interface. On another end of enpoint runned bash. I'm try ssh/terminal package but when i'm use it and enter date command i get something like: [root@143177 ~]# [root@143177 ~]# [root@143177 ~]# [root@143177 ~]# date[root@143177 ~]# [root@143177 ~]# [root@143177 ~]# bash: [root@143177: command not found[root@143177 ~]# [root@143177 ~]# [root@143177 ~]# bash: [root@143177: command not found[root@143177 ~]# [root@143177 ~]# [root@143177 ~]# bash: [root@143177: command not found[root@143177 ~]# [root@143177 ~]# [root@143177 ~]# datebash: [root@143177: command not found[root@143177 ~]# [root@143177 ~]# [root@143177 ~]# bash: [root@143177: command not found[root@143177 ~]# [root@143177 ~]# [root@143177 ~]# [root@143177 ~]# custom ReadWriter when Read returns recieved data immediately if it present, writer blocks while write data and returns when all data in buffer writed. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Re: i/o timeout when using bufio on net connection (tcp)
2017-04-17 19:05 GMT+03:00 Kevin Johnson : > Hi Vasiliy, > > I spent a few minutes looking at your program and a couple things jumped out > at me. As you are probably aware, writes on a network socket usually return > the number of bytes written, This is because if the TCP buffer fills, then > the write call will return only the amount that got added. I noticed you > used a timeout on the TCP conn, which probably puts the connection into > non-blocking mode. I would be surprised if binary.write was smart enough to > attempt multiple writes in case of a partial write. You might try removing > the time-out and see if that has any effect. (Network non-blocking writes > may wait for the entire write to succeed before returning). You might also > use the binary.write to write to a local block of bytes and then use the > conn send to send them manually, resending the parts when the writes only > partially complete. Ok, thanks! I'm try to write to buffer and use simple net.Conn Write. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] C union type to go native types
I have Some C struct like https://libvirt.org/html/libvirt-libvirt-common.html#virTypedParameter that needs to be binary Unmarshal to go native interface (xdr2), does it possible to represent via one go struct all needed things, or i need to create for each type struct and provide needed interface methods ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] i/o timeout when using bufio on net connection (tcp)
Hi! I have some client-server app, that uses tcp to connect to remote server. After connection established i'm try to download/upload 21G file (download/upload in the same time so after recieve 26K data i'm send it to remote server) after 700-900Mb i have i/o timeout errors: dst write tcp [2a04:ac00:6:1::1]:57048->[2a04:ac00:4:10:ec4:7aff:fe54:cb0a]:16509: i/o timeout tcpdump on server says that when i have this errors no traffic goes from my to remote server. Data flow not simple, but main parts are in https://github.com/vtolstov/go-libvirt/blob/master/client/stream.go#L141 and https://github.com/vtolstov/go-libvirt/blob/master/client/rpc.go#L246 what can i do to fix this timeouts ? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] usability question
Hi. I'm writing libvirt binding (without cgo) based on digitalocean libvirt binding. And now we stuck at api design. What is the preffered api design for go package/binding Please read https://github.com/digitalocean/go-libvirt/issues/32 all comments and say, what api is preferred in case of user POV. Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] static compile binary with newlib instead of glibc
2017-03-17 16:59 GMT+03:00 Ian Lance Taylor : > Go can statically link a binary without any C library at all. The > question of using a C library only comes in when cgo to call C code. > I suspect that right now Go programs that use cgo will fail to build > with newlib, because the runtime/cgo package expects to be able to > call functions like pthread_create that, last time I looked, newlib > does not provide. Thanks! -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.