Re: [go-nuts] Allow go mod download to store in subdirectory of current working directory

2019-03-04 Thread Marcin Romaszewicz
Can you accomplish what you want with module vendoring? Before I set up my own Athens proxy, I was using that to avoid DDOSing github in my build automation, and it seemed to work fine. Your first pipeline step could vendor in all the modules, and subsequent pipeline steps would use those. -- Marc

Re: [go-nuts] regarding os package & env variable setting

2019-03-05 Thread Marcin Romaszewicz
os.Setenv only changes the environment variables in your process and in any future child processes. It's not actually possible to change the environment of your parent process or the OS through this mechanism. -- Marcin On Tue, Mar 5, 2019 at 6:00 AM wrote: > Hi, > I am trying to enable tls 1.

Re: [go-nuts] Implementing an EventBus in Go

2019-03-10 Thread Marcin Romaszewicz
Channels are producer/consumer queues, they don't handle one to many broadcasting, you'd need one channel per subscriber then you'd queue the message to each of them. In my opinion, they work more nicely than callbacks, since your handler can run in its own execution context, and not in the callbac

Re: [go-nuts] Module replacement forks and Artifactory

2019-03-11 Thread Marcin Romaszewicz
I've been beating my head into this recently as well, and I'm not done yet so I can't say this works for sure, but the workaround appears to be a virtual Go repository in Artifactory. You would create a Go repository for github.com and another for , then create a virtual repository on top of those

Re: [go-nuts] Persistence of value, or Safely close what you expected

2019-03-13 Thread Marcin Romaszewicz
Your program is most certainly non-deterministic, and you will sometimes close a closed channel and panic. There is no thread safe way to test if a channel is closed, then close it if it isn't. I think of channel ownership in a similar way as of memory ownership in C/C++. If this channel is being

Re: [go-nuts] I am starting Golang and I am looking for a example to Login, Logout, Signup..

2019-03-19 Thread Marcin Romaszewicz
I build these kinds of things for a living, and sadly, there isn't very much in pure Go that I'm aware of to do this. I have a bunch of Go code which I use to do this, but sadly, I can't share it yet, as I'm working on getting approval to open source it. The quickest way might be to put a SAML or

Re: [go-nuts] Go Need help _ suddenly all teh unit test in Go Stopped working

2019-03-25 Thread Marcin Romaszewicz
Go is telling you what is wrong in that message. You have a file `C:\Users\Gini Joseph\GoWorkspace\pkg\mod\github.com \stretchr\testify@v1.3.0\mock\mock_test.go` which does not have the expected "package" line at the top of the file, because the file is empty (EOF = end of file). So, as a first s

Re: [go-nuts] [ANN] GoLand 2019.1 is out

2019-03-27 Thread Marcin Romaszewicz
Thank you! You guys build a fantastic IDE. -- Marcin On Wed, Mar 27, 2019 at 8:59 AM Florin Pățan wrote: > Hello gophers, > > > I'm happy to let you know that we just released GoLand 2019.1. > > Here are a few things you can find in this release: > >- Built-in Profiler support for CPU, Memo

Re: [go-nuts] Re: Decimal survey

2019-03-28 Thread Marcin Romaszewicz
A huge +1 on that last comment. You never want to store currency in floating point, but rather some form of fixed point notation, like your pennies suggestion. Compounding errors on floating point representations of currency kill you. For example, $0.01 is not exactly representable as float. How m

Re: [go-nuts] why is this not ascending?

2019-04-08 Thread Marcin Romaszewicz
I added this at the top of your main "fmt.Println("CPU Count", runtime.NumCPU())", and found out that the playground uses 1 CPU, so your goroutines will not run concurrently. The scheduler will do a context switch whenever you call a any number of runtime functions, but it is fundamentally coopera

Re: [go-nuts] Using C++ code with cgo

2019-04-11 Thread Marcin Romaszewicz
Wrap your C++ code in C. Create a header which is simply: cwrapper.h: void printSomething() Then you can have a cwrapper.cpp instead of your wrapper.hpp: #include extern "C" { void printSomething() { printf("Hello World"); } } Your C++ code will produce a function named printSomething with

Re: [go-nuts] What is recommended way to initialize and keep prepared statements in go Lang

2019-04-13 Thread Marcin Romaszewicz
Do you mean a SQL prepared statement? Check out the database/sql package. The database connection abstraction has a Prepare function which creates a statement. Keep in mind, that based on your level of concurrency, the statement will be re-prepared in each new connection that's opened up on your b

Re: [go-nuts] What is recommended way to initialize and keep prepared statements in go Lang

2019-04-14 Thread Marcin Romaszewicz
repare statements this struct will keep on > increasing so my question was is there any better way provided in golang > like in java (where we can initialize prepare statement in class > constructor and use that ) > > On Sun, Apr 14, 2019 at 7:59 AM Marcin Romaszewicz > wrote: > >> D

Re: [go-nuts] Does anyone know how to implement dynamic two-dimensional arrays ??

2019-04-20 Thread Marcin Romaszewicz
I fixed your example with some explanatory comments: https://play.golang.org/p/zwt78CPwxk_o package main import ( "fmt" ) func main() { Af(5) } func Af ( N int) { //Initialize outer array, you get an array of 25 nil arrays M := make( [][]uint16, N*N,N*N) for y:=0; y< N; y++ { // Initi

Re: [go-nuts] go build *.exe file size seems much too large

2019-04-21 Thread Marcin Romaszewicz
It contains the Go runtime - memory manager, goroutine scheduler, all that. -- Marcin On Sun, Apr 21, 2019 at 7:16 PM wrote: > For this simple go code, the *.exe file size is 1800 KB ...why so large > compared to equivalent C-compiled code ?? > package main > import( "math"; "fmt" ) > func mai

Re: [go-nuts] What does "identifier...type" mean in a function definition?

2019-04-25 Thread Marcin Romaszewicz
You have three tokens in "args ... interface{}", (args) (...) (interface{}), the spacing doesn't matter in this case. It's just like in C, you can have int *foo or int* foo. Semantically, the two are the same. -- Marcin On Thu, Apr 25, 2019 at 12:35 PM Andrew Price wrote: > Hey folks, > > A col

[go-nuts] Releasing an open source client/server generator for Swagger

2019-04-26 Thread Marcin Romaszewicz
Hi All, These days, spec-driven development of REST API's is quite common, and I've had to reinvent this wheel more than once, so my gracious employer has allowed me to open source my work. https://github.com/deepmap/oapi-codegen This is like protocol buffer specifications for JSON/REST. You can

Re: [go-nuts] Re: Get fingerprint of ca

2019-04-30 Thread 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

Re: [go-nuts] Re: Get fingerprint of ca

2019-04-30 Thread Marcin Romaszewicz
p 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 On Tue, Apr 30, 2019 at 1:12 PM Vasiliy Tolstov wrote: > вт, 30 апр. 2019 г. в

Re: [go-nuts] Random panic in production with Sprintf

2019-05-02 Thread Marcin Romaszewicz
If that's the actual problem, you'd just be masking it, and producing an invalid "x". Look here: func (r *Subid_info) Prepare_subid_logic(){ r.Second_subid_8=fmt.Sprintf("1%07v", r.Second_subid) > panic happens here. } r.Second_subid is in an invalid state which normal Go code could not c

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Marcin Romaszewicz
Consider this: var something []interface{} var anotherThing []SomeType append(something, anotherThing) Does the compiler know here whether I want to append "anotherThing" or " anotherThing..."? It has no way to know, and both would work, so that's why we give it a hint with the ellipsis symbol.

Re: [go-nuts] Go-SQLite3: Convert between string and slice

2019-05-05 Thread Marcin Romaszewicz
Define a type: type Countries []Country Then, for that type, implement the sql.Scanner and sql.Valuer interfaces. You could, for example, marshal your state array as a list of comma separated states. You're not casting, but providing customer scanners/readers for your data type which convert it f

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-05 Thread Marcin Romaszewicz
I've done quite a bit of MP programming over 20+ years now, and skimming your code, I see a number of issues. There are probably a lot more that I don't. In the latest go playground link Line14: if "if wg.started {" has a race condition, both on accessing the variable, and logically, in that two g

Re: [go-nuts] Re: Web access to golang-dev is down

2019-05-07 Thread Marcin Romaszewicz
The same for me. golang-dev is not accessible to me, nor does it show up in a group search, meaning it's not visible to me. I'm not a registered member of it, so it appears to no longer be a public group. -- Marcin On Tue, May 7, 2019 at 7:57 AM wrote: > Sorry, forgot to include: Yes, I can ac

Re: [go-nuts] Install Lastest Modules

2019-05-14 Thread Marcin Romaszewicz
go get -u github.com/360EntSecGroup-Skylar/excelize/v2 will do what you want. You then have to import " github.com/360EntSecGroup-Skylar/excelize/v2" in all your Go files. -- Marcin On Tue, May 14, 2019 at 3:37 PM Andrew wrote: > I want to install the latest version(v2.0.0) of excelize library

Re: [go-nuts] Getting type information from name as a string

2019-05-21 Thread Marcin Romaszewicz
That's what the reflect package does, https://play.golang.org/p/M7gNcKjOmMM -- Marcin On Tue, May 21, 2019 at 8:15 PM wrote: > Hi, > > for a code generator I want to get a type of a string which is passed by > an argument by go generate. So I have sth. like "[]int" and now I need to > know if

Re: [go-nuts] How do you keep your modules up-to-date?

2019-05-30 Thread Marcin Romaszewicz
I have the same kind of setup at my company, and we use go modules in the same way that we would use public modules. We periodically do a "go get -u" to update them. Jenkins does that once a week, so at worst, we're a week behind. If someone needs to manually pull in changes more urgently, they can

Re: [go-nuts] There are post-quantum public key cryptograph in Go ? or binds to Go? Thanks.

2019-06-07 Thread Marcin Romaszewicz
The NIST publishes some recommendations for applied cryptography, and they've amended their recommendations recently away from some quantum-weak algorithms. Here's a good starting point for reading. Your biggest cryptography p

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Marcin Romaszewicz
I think the others were correct in pointing the finger at the RegEx engine in Go. It is quite slow. I hacked your inside loop which checks the request not to use regular expressions, and it's tons faster. You can't say that something can't be responsible for too much slowdown because it "1 line", s

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Marcin Romaszewicz
esponse() response.Header().Add("Connection", "close") response.Header().Add("ETag", "dbab") response.Header().Add("Cache-Control", "public, max-age=31536000") response.Header().Add("Content-length", strconv.I

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-10 Thread Marcin Romaszewicz
4 0.8 4 11 Percentage of the requests served within a certain time (ms) 50% 4 66% 4 75% 5 80% 5 90% 5 95% 5 98% 6 99% 6 100% 11 (longest request) On Mon, Jun 10, 2019 at 4:12 PM Marcin Romaszewicz wrote: > One more follo

Re: [go-nuts] Concerning the level required to contribute to Go

2019-06-21 Thread Marcin Romaszewicz
So, I'm not a Go contributor, but I've been doing this software-for-a-living thing for about 25 years now, but never in these years have I experience some kind of read/not ready transition. When I was less experienced, I thought I knew a lot more than I did, now that I know an order of magnitude mo

Re: [go-nuts] sudo ./main command throwing error

2019-06-24 Thread Marcin Romaszewicz
sudo does not preserve environment variables for security reasons, run: sudo echo $LD_LIBRARY_PATH You'll likely see that it's empty, unless you have a global system one set. On Mon, Jun 24, 2019 at 9:48 AM Nitish Saboo wrote: > Hi , > > I am using cgo in this project where I need the followi

Re: Re: [go-nuts] How go-mysql-driver get data? "get all data at a time" or "only get a batch when we call rows.Next"?

2019-06-26 Thread Marcin Romaszewicz
No, it doesn't get all the data in the Next() call, it streams it incrementally from the DB. I've used it to stream gigabytes before, and they certainly didn't get buffered in RAM. On Wed, Jun 26, 2019 at 11:04 AM wrote: > Get all data in the first Next() call? or only get a batch? > > At2019-06

Re: [go-nuts] Some thoughts on query building in Go

2019-07-13 Thread Marcin Romaszewicz
I think that query builders are nice to have and proofs of concept are simple for simple queries, but the moment you need to leave the simple query domain and do something a little more complicated, things start to fall apart. As an example, say you want to store a struct in a database which contai

Re: [go-nuts] Re: About the Google logo on the new Go website

2019-07-15 Thread Marcin Romaszewicz
I used to work at Google at the time that Go was created, and these are my own observations. Google isn't making zillions off Go. Google makes zillions off advertising and is trying to make money other ways, but not always very successfully. Go really was designed as a nice to use systems language

Re: [go-nuts] Re: prevent alteration of binaries once distributed in the wild?

2019-07-23 Thread Marcin Romaszewicz
Don't be too afraid of governments tampering with your program, I mean this in the best possible way, but you are nobody important enough :) Governments issue subpoenas, arrest warrants, and issue court orders - that's much quicker and more effective than hacking. In the security space, we also ref

[go-nuts] Module can't find itself

2019-07-24 Thread Marcin Romaszewicz
Hi All, I've got a module problem which I don't quite understand. All my code is here: https://github.com/deepmap/oapi-codegen When I run "go build" from the top of the repo, I get: $ go build can't load package: package github.com/deepmap/oapi-codegen: unknown import path "github.com/deepmap/oap

Re: [go-nuts] Module can't find itself

2019-07-24 Thread Marcin Romaszewicz
Thanks, and duh :) I was so busy trying to figure out why it wasn't building that I neglected to check the basics. -- Marcin On Wed, Jul 24, 2019 at 9:31 PM Burak Serdar wrote: > On Wed, Jul 24, 2019 at 10:11 PM Marcin Romaszewicz > wrote: > > > > Hi All, > >

Re: [go-nuts] panic: interface conversion: interface is nil, not encoding.BinaryUnmarshaler

2019-08-14 Thread Marcin Romaszewicz
Here you go: https://play.golang.org/p/_cPmaSxRatC You want to unmarshal into &A, not into &Duck This means: var duck2 A not: var duck2 Duck On Wed, Aug 14, 2019 at 8:46 AM Jochen Voss wrote: > Hello, > > I'm trying to read gob-encoded data into a variable of interface type. In > simple case

Re: [go-nuts] Re: Running tests per package with Go module

2019-08-20 Thread Marcin Romaszewicz
It could fail if you're under $GOPATH and GO111MODULE=auto, since inside the GOPATH, auto=off -- Marcin On Tue, Aug 20, 2019 at 12:43 PM Jacques Supcik wrote: > Hello Chris, > > I made a small project with the same structure as yours to reproduce the > problem : https://github.com/supcik/rtppw

Re: [go-nuts] Re: An old problem: lack of priority select cases

2019-08-28 Thread Marcin Romaszewicz
Think of a channel as existing for the lifetime of a particular data stream, and not have it be associated with either producer or consumer. Here's an example: https://play.golang.org/p/aEAXXtz2X1g The channel here is closed after all producers have exited, and all consumers continue to run until

Re: [go-nuts] ticker not firing often enough in minimal mac app with run loop

2019-09-04 Thread Marcin Romaszewicz
I'm not quite sure how to avoid this, but I'm pretty sure that I know the cause. Read up on Grand Central Dispatch and Centralized Task Scheduling ( https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/DiscretionaryTasks.html). It's been a

Re: [go-nuts] How to do a forward compatibility support for go 1.13?

2019-09-06 Thread Marcin Romaszewicz
This may not be the exact answer you're looking for, but there's a package which handles this even better than Go's builtin error package: https://github.com/pkg/errors Dave Cheney's package is better designed, IMO, and the explicit errors.Wrap() call is more clear than inferring it from your for

Re: [go-nuts] sqlserver error "TLS Handshake failed: x509: certificate signed by unknown authority"

2019-09-10 Thread Marcin Romaszewicz
You're missing the CA Root certificates for whatever linux distribution is running your application. For example, I use Alpine linux as my Docker base image for my Go services, and I must install the certificates like this via the Dockerfile: RUN apk update && apk add ca-certificates Find the cor

Re: [go-nuts] Need a Modules for Dummy's Guide. Please help

2019-09-23 Thread Marcin Romaszewicz
I've beat my head into the module wall a bit as well, and while I don't understand some of the design decisions, I've done my best to answer your questions inline. On Mon, Sep 23, 2019 at 1:42 PM Stuart Davies wrote: > Hi. > > > > I have been using GO for about a year and I love the language and

Re: [go-nuts] nil map assignment panics. can we do better?

2019-09-24 Thread Marcin Romaszewicz
Could we have an operation like append() for slices? How about: m := insert(m, "key", "value"). It returns m unchanged if it's allocated, otherwise, it allocates. We're already familiar with this kind of function. -- Marcin On Mon, Sep 23, 2019 at 10:58 PM abuchanan via golang-nuts < golang-nu

Re: [go-nuts] go 1.13 won't compile

2019-09-28 Thread Marcin Romaszewicz
What was the last version of Go which worked for you? "dsrt" isn't a valid module path in the new module resolution code. Does it work if you disable modules - "GO111MODULE=off go install dsrt"? On Sun, Sep 22, 2019 at 9:56 AM rob wrote: > Hi. I think I'm having an issue compiling my code w/

Re: [go-nuts] Golang library for - ORM & Schema Migration

2019-09-28 Thread Marcin Romaszewicz
I've used naked SQL, and ORMs (Django in Python, Hibernate and EBean in Java, GORM in Go) for years, and I've noticed the following: 1) It's really easy to write very inefficient queries in an ORM. If you have a very simple 1:1 mapping between tables and objects, it's fast, efficient, easy to use,

Re: [go-nuts] go 1.13 won't compile

2019-09-30 Thread Marcin Romaszewicz
I have written other small programs in go that I use for myself. I >>>>> put it in https://play.golang.org/p/U7FgzpqCh-B >>>>> >>>>> It compiles and runs fine on go 1.12.x under linux, and fine on go >>>>> 1.13 under windows 10. I have not yet installed g

Re: [go-nuts] ent: an entity framework for Go

2019-10-03 Thread Marcin Romaszewicz
That looks very nice, congrats! I like that it's simple and doesn't try to solve every problem, just simple relationships, so you can solve most of your simple DB schema needs (and most DB usage is quite simple in most services). Do you have any plans to add a Postgres driver? -- Marcin On Thu,

Re: [go-nuts] Re: An old problem: lack of priority select cases

2019-10-04 Thread Marcin Romaszewicz
What he's trying to say is that it is pointless to order select cases in this example, because it is impossible to guarantee ordering in an asynchronous system. You have two asynchronous data streams, ctx.Done() and "v", in that example above. Generally, those select cases will happen one by one,

Re: [go-nuts] Re: [64]byte()[:]

2019-11-16 Thread Marcin Romaszewicz
It's not even worth calling bytes.Equal to see if a bunch of bytes is zero. A more efficient way would be to simply loop over them and check for non-zero. -- Marcin On Sat, Nov 16, 2019 at 4:00 PM Kevin Malachowski wrote: > "make"ing a byre slice every time you call Equal is not likely as > eff

[go-nuts] Is anyone aware of a blocking ring buffer implementation?

2019-11-21 Thread Marcin Romaszewicz
Hi All, Before I reinvent the wheel, and because this wheel is particularly tricky to get right, I was wondering if anyone was aware of a a library providing something like this - conforms to io.Reader - conforms to io.Writer - Contains a buffer of fixed size, say, 64MB. If you try to write when

Re: [go-nuts] Is anyone aware of a blocking ring buffer implementation?

2019-11-21 Thread Marcin Romaszewicz
implementation though). > > > On Nov 21, 2019, at 10:20 PM, Dan Kortschak wrote: > > > > There is this: https://godoc.org/bitbucket.org/ausocean/utils/ring > > > > It has been used in production fairly extensively. > > > >> On Thu, 2019-11-21 at 19:

Re: [go-nuts] Is anyone aware of a blocking ring buffer implementation?

2019-11-23 Thread Marcin Romaszewicz
is needed to fix > the problem. > > On Nov 21, 2019, at 11:18 PM, Marcin Romaszewicz > wrote: > >  > I am in fact replacing an io.Pipe implementation, because I need to buffer > some data. io.Pipe doesn't buffer, it just matches up read and writes with > each other.

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Marcin Romaszewicz
It's very simple to do that: https://play.golang.org/p/1i7pI2OXmej On Sun, Dec 1, 2019 at 8:22 AM Vital Nabokov wrote: > Разбить массив чисел на два массива? > Split an array of numbers into two arrays? > > -- > You received this message because you are subscribed to the Google Groups > "golan

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Marcin Romaszewicz
oftware Engineer > github.com/danicat > twitter.com/danicat83 > > > Em dom., 1 de dez. de 2019 às 17:07, Marcin Romaszewicz > escreveu: > >> It's very simple to do that: >> https://play.golang.org/p/1i7pI2OXmej >> >> >> >> On Sun, Dec 1, 201

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread Marcin Romaszewicz
As a bonus challenge, try to compute the population center of Brazil :) One way of finding the center is minimizing the integral of all distances to a point, but for population, these points now have weight. Like Michael above, I spent years working on Google Earth, and the code running in the lat

Re: [go-nuts] How to have fixed xml attributes "Header"

2019-12-12 Thread Marcin Romaszewicz
Could you share your code which isn't working? Here's a simple example of how you would do something like that, but not knowing your code, it might not be helpful. https://play.golang.org/p/H-9eCTYJxTA On Thu, Dec 12, 2019 at 9:57 AM paresh patil wrote: > Hi, > > > I'm new to Go and finding it

Re: [go-nuts] How to have fixed xml attributes "Header"

2019-12-12 Thread Marcin Romaszewicz
gt; Let me know your thoughts > > Thanks > > On Thu, Dec 12, 2019 at 6:14 PM Marcin Romaszewicz > wrote: > >> Could you share your code which isn't working? >> >> Here's a simple example of how you would do something like that, but not >> kno

Re: [go-nuts] How to mock structs with interdependent interface methods?

2019-12-12 Thread Marcin Romaszewicz
I face similar problems in a lot of production Go code which I write. I do have an answer for this, but it's not pretty. Your code would look something like this: type ResourceGetter interface { GetResource(id string) (*Resource, error) } type ResourceManagerImpl struct { rg ResourceGetter

Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread Marcin Romaszewicz
Error is an interface, so its type depends on the implementation satisfying that interface. You can't just create an "error", since they don't exist, all that exists are implementation satisfying the error interface. That's what you're doing with NewSignature. Could you just create an implementati

Re: [go-nuts] [Proposal] database/sql: add interface that unite DB and Tx

2020-01-16 Thread Marcin Romaszewicz
I have that exact interface in all of my DB code, and I never use sql.Tx or sql.DB directly. You don't need Go's libraries to adopt this at all, just use your own. On Wed, Jan 15, 2020 at 11:20 PM Mhd Shulhan wrote: > ## Problem > > At some point we have a function that receive an instance of da

Re: [go-nuts] Question about 'import' statement

2020-02-03 Thread Marcin Romaszewicz
All the files get downloaded to your $GOPATH/src or $GOPATH/pkg, depending on whether modules are enabled. Everything gets compiled together into the same static executable, so yes, the files get compiled. The order of imports should not matter in well written code, but you can always create scen

Re: [go-nuts] Why Discord is switching from Go to Rust

2020-02-07 Thread Marcin Romaszewicz
You're not oversimplifying. GC incurs a price, and that's performance. If you have a program which manages its own memory optimally for its usage pattern, it will be more efficient than a generic GC that has to handle all usage patterns. I use Go everywhere I can, since the tradeoff between program

Re: [go-nuts] Why Discord is switching from Go to Rust

2020-02-07 Thread Marcin Romaszewicz
doop. With the Go services, most of our engineers time is spent writing the initial code and tests. With Java, most of their time is spent chasing Java memory allocation issues. I think the place the effort goes speaks volumes about how well the GC works in both languages. > On Feb 7, 2020, at 12:57

Re: [go-nuts] Go without garbage collector

2020-02-12 Thread Marcin Romaszewicz
Your paper proves your conclusions given your assumptions :) When there is no GC runtime in a language, you are open to managing memory however you see fit, and there are lots of models which are more efficient than reference counted smart pointers or whatever. I've worked on many realtime systems

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Marcin Romaszewicz
I'm using Uber's zap logger in production systems ( https://github.com/uber-go/zap). It is designed to emit structured JSON logs and do the minimal amount of allocations possible. It's a completely different interface from Go's log package, but that is where the efficiency comes from. I'd highly re

Re: [go-nuts] Using modules with private repos

2020-03-11 Thread Marcin Romaszewicz
There is really no nicer way. You do not have to make those .insteadOf overrides in your global git config, though, you can do it in the local git config for your Go repository to contain the damage. You will also find that private repositories don't work nicely with things like the Athens module p

Re: [go-nuts] How to break-out of martini middleware

2020-03-15 Thread Marcin Romaszewicz
Martini is defunct, but Gin took their torch and ran with it. I use such http routing frameworks as part of my day job, and would recommend the three following ones. 1) Echo (https://github.com/labstack/echo) 2) Gin (https://github.com/gin-gonic/gin) 3) Chi (https://github.com/go-chi/chi) I would

Re: [go-nuts] If in doubt prefer to wrap errors with %v, not %w?

2020-03-22 Thread Marcin Romaszewicz
In my opinion, this is a much nicer errors package than Go's library, and I've been using it everywhere: https://github.com/pkg/errors Instead of fmt.Errorf("%w"), you do errors.Wrap(err, "message"), and errors.Unwrap(...) where you want to inspect the error. It's much more explicit and less error

Re: [go-nuts] Any reason why this type conversion is not allowed?

2020-04-13 Thread Marcin Romaszewicz
Go doesn't do any implicit type conversions, and it's quite consistent about that. The only things which are type "converted" are untyped constants. I would love for this to work too, by the way, since I often come up with something like: var a []interface{} var b []SomethingConcrete I would lov

Re: [go-nuts] Appending to a slice of an array on the stack

2020-04-18 Thread Marcin Romaszewicz
I added a little more to your example to illustrate my email points. https://play.golang.org/p/eT5tKUniC1E 1) stack_array may or may not be on the stack, Go makes that choice. 2) slice := stack_array[:] Doesn't copy the data, it creates a slice structure which wraps it. 3) Next, when you call sl

Re: [go-nuts] Json Parse Data [unexecpted non whitespace 1 to 28]

2020-04-28 Thread Marcin Romaszewicz
Ali, your example has several problems. First, you do this: var p Person data, err := json.Marshal(p); if err != nil{ fmt.Println("Error", err) } What this does is encode an empty object, that's fine. Next, you read the HTTP body from the request, and try to unmarshal that. fmt.Println("Data",

Re: [go-nuts] Is this a safe way to block main thread but not main goroutine?

2020-04-29 Thread Marcin Romaszewicz
As Thomas said, this will work for sure, though, and doesn't require any manual setup, and you don't need to do funny business with CGO. func main() { go doAllYourOtherStuff() blockOnDarwinEventLoop() } Done. On Wed, Apr 29, 2020 at 1:44 PM Akhil Indurti wrote: > I want to mirror (or cont

Re: [go-nuts] Re: recommended approach for loading private keys requiring passwords

2020-05-02 Thread Marcin Romaszewicz
Haha, great minds think alike, as they say. One of my colleagues (from a cloud security company) wrote basically the same thing in Go: https://github.com/cloudtools/ssh-cert-authority There's also a really fantastic product that works via signed SSH certs called Teleport

Re: [go-nuts] Get name of struct implementing interface using interface method, reflection

2020-05-08 Thread Marcin Romaszewicz
Go isn't polymorphic, whenever your String() function is called, it's on BaseFoo, you have to do it like this: https://play.golang.org/p/69rw0jRPalz On Fri, May 8, 2020 at 1:43 PM Glen Newton wrote: > Thanks! > > Oh no, when I try that here: https://play.golang.org/p/RV-S4MJWYUi > Did not work:

Re: [go-nuts] Best practice for Database Open and Close connection

2020-05-27 Thread Marcin Romaszewicz
Behind the scenes, DB is actually a connection pool, not a single connection, which will open new connections when you need them. In our services - which do a LOT of DB work, we only open a single sql.DB connection and share it among all our handlers. Whenever a handler does a db.Whatever, the db

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

2020-06-18 Thread Marcin Romaszewicz
I'd like to add a big +1 here. The proposal around contracts and generics is solid from a conceptual perspective, and I enjoyed reading the rationale behind what's supported, and what isn't, and I think this is a wonderful addition to the language which keeps type safety in a very Go-like way despi

[go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-05 Thread Marcin Romaszewicz
Hi All, I'm hitting a problem using os.exec Cmd.Start to run a process. I'm setting Cmd.Stdio and Cmd.Stderr to the same instance of an io.Pipe, and spawn a Goroutine to consume the pipe reader until I reach EOF. I then call cmd.Start(), do some additional work, and call cmd.Wait(). The runtime o

Re: [go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-05 Thread Marcin Romaszewicz
On Sun, Jul 5, 2020 at 1:05 PM Ian Lance Taylor wrote: > On Sun, Jul 5, 2020 at 10:54 AM Marcin Romaszewicz > wrote: > > > > I'm hitting a problem using os.exec Cmd.Start to run a process. > > > > I'm setting Cmd.Stdio and Cmd.Stderr to the same instanc

Re: [go-nuts] I need help with a timer.

2020-07-06 Thread Marcin Romaszewicz
This would do it: https://play.golang.org/p/x2AyQWxJh4S On Mon, Jul 6, 2020 at 9:47 AM Khan wrote: > Hey! I'm pretty new to prgramming in general and i've been trying to > figure out something for a little while now and just couldn't get it done. > So i decided to ask for help here! > I just wa

Re: [go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-06 Thread Marcin Romaszewicz
:14 PM Marcin Romaszewicz > wrote: > > > > On Sun, Jul 5, 2020 at 1:05 PM Ian Lance Taylor wrote: > >> > >> On Sun, Jul 5, 2020 at 10:54 AM Marcin Romaszewicz > wrote: > >> > > >> > I'm hitting a problem using os.exec Cmd.Start to run a proce

Re: [go-nuts] What can cause a process launched via os.exec to sporadically die from SIGPIPE

2020-07-06 Thread Marcin Romaszewicz
Thanks for the tip, I wasn't aware that happened! I'll use os.Pipe. -- Marcin On Mon, Jul 6, 2020 at 4:45 PM Ian Lance Taylor wrote: > On Mon, Jul 6, 2020 at 4:42 PM Marcin Romaszewicz > wrote: > > > > Yes, I am using io.Pipe, and passing in the PipeWriter side

Re: [go-nuts] Re: Quick question about calling Set-Cookie twice in a row

2020-07-14 Thread Marcin Romaszewicz
The Go http code calls Header.Add() on your cookie, and Header.Add will concatenate values together. If you want replacement semantics, you'll have to clearout the "Set-Cookie" header on the response, or only add your final cookie. On Tue, Jul 14, 2020 at 4:58 PM B Carr wrote: > In my applicatio

Re: [go-nuts] Pipe multiple commands in golang

2020-08-12 Thread Marcin Romaszewicz
You have two options here. One, is you execute a shell, and just tell the shell to run your command, eg bash -c "strings dynamic_file_path | grep regex". The other option is that you exec strings and grep independently, and connect the two of them using an os.pipe, but it's a lot more work to do

Re: [go-nuts] Share GOMODCACHE between unix users

2020-08-19 Thread Marcin Romaszewicz
I have many users building Go at my company, and instead of sharing the module cache on the filesystem, a much better approach is to use a caching module proxy, such as Athens (https://github.com/gomods/athens). See the documentation for the GOPROXY environment variable. -- Marcin On Wed, Aug 19

Re: [go-nuts] Re: Share GOMODCACHE between unix users

2020-08-19 Thread Marcin Romaszewicz
Yes, each user would populate their own module cache locally if using your own proxy. On Wed, Aug 19, 2020 at 10:04 AM wilk wrote: > On 19-08-2020, Marcin Romaszewicz wrote: > > --71f06b05ad3dc9f8 > > Content-Type: text/plain; charset="UTF-8" > > >

Re: [go-nuts] Workflow and tools for JSON Schema generation

2020-09-04 Thread Marcin Romaszewicz
Have you considered reversing the workflow? You write the OpenAPI spec, and have a code generator produce the Schemas and server boilerplate? If that's ok, check out my project :) https://github.com/deepmap/oapi-codegen We successfully use it for many API's in production. -- Marcin On Thu, Sep

Re: [go-nuts] Workflow and tools for JSON Schema generation

2020-09-04 Thread Marcin Romaszewicz
ore stable, and less convoluted. V1 was a learning experience. On Fri, Sep 4, 2020 at 10:56 AM Marcin Romaszewicz wrote: > Have you considered reversing the workflow? You write the OpenAPI spec, > and have a code generator produce the Schemas and server boilerplate? > > If that'

Re: [go-nuts] database/sql doesn't return error for query-string-destination if NULL bug or feature

2020-09-11 Thread Marcin Romaszewicz
Which sqlite driver are you using? That sounds like a bug. On Fri, Sep 11, 2020 at 10:56 AM Stephan Lukits wrote: > I passed a string-type pointer (as last destination) to a sql.DB.Query > call which had a NULL value as field value. No error was returned and all > other fields got the appropriat

Re: [go-nuts] Cross compiling for linux from dawin

2020-09-22 Thread Marcin Romaszewicz
Your compiler environment for C code is still building for Darwin, most likely. You need to set up a cross compiler and use cgo ( https://golang.org/cmd/cgo/). $CC should invoke your cross compiler. On Tue, Sep 22, 2020 at 11:19 AM Mixo Ndleve wrote: > Experiencing this problem when "github.com/

Re: [go-nuts] Re: How to create UTC date without extra UTC string

2020-09-23 Thread Marcin Romaszewicz
See https://golang.org/pkg/time/#Time.Format Here's how to use it. I think this is exactly what you want: https://play.golang.org/p/3r0TFtOmtqF On Wed, Sep 23, 2020 at 11:43 AM Alex Mills wrote: > My guess, is that a starting place would be something like: > > > *var s = time.Now().UTC().String

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

2020-10-05 Thread Marcin Romaszewicz
On Mon, Oct 5, 2020 at 10:31 AM Vladimir Varankin wrote: > > Or, it will be written as assert.Equal(got, want, > fmt.Sprintf("MyFunction(%v)", input)), but that is harder to write, and > therefore less likely to be written. > > That obviously depends on the implementation details but since we tal

Re: [go-nuts] ECDSA signature verification

2020-10-07 Thread Marcin Romaszewicz
secp256r1 has been hand optimized for performance, the others haven't. If performance there matters to you, it's actually faster to call out to C libraries to verify 384 and 512 bit curves. On Wed, Oct 7, 2020 at 9:27 AM Shobhit Srivastava wrote: > Hi All > > I have tried to do the performance

Re: [go-nuts] ECDSA signature verification

2020-10-08 Thread Marcin Romaszewicz
se it. >> >> Will check out the C library. Thanks >> >> >> >> On Wed, 7 Oct 2020, 22:22 Marcin Romaszewicz, wrote: >> >>> secp256r1 has been hand optimized for performance, the others haven't. >>> >>> If performance

Re: [go-nuts] ECDSA signature verification

2020-10-08 Thread Marcin Romaszewicz
; Thanks for the pointers for the library. Just a quick question, do you > think calling C library from Go can give great results for 521 curve. > > > > On Thu, 8 Oct 2020, 21:03 Marcin Romaszewicz, wrote: > >> My issue was slightly different than yours, in that I was burning

Re: [go-nuts] net/http TLS issue

2020-10-16 Thread Marcin Romaszewicz
Having a passcode to protect a key file for a production service is pointless, because you move the problem of storing the certificate securely to the problem of storing the passcode securely, so might as well skip the passcode and store the cert securely. Your certificate is probably encoded as a

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

2020-10-20 Thread Marcin Romaszewicz
Go's database layer is generally pretty quick, I use it a lot, but your code immediately sets off my DB alarms, because you are doing queries within the body of another query loop, which means you're opening up lots of connections, which could be slow. I'd reorganize as followd. - Cache the resul

  1   2   >