Quantcast
Channel: User Norbert - Stack Overflow
Browsing latest articles
Browse All 42 View Live
↧

Comment by Norbert on MySql JOIN syntax with multiple tables

For the performance: I would say that the performance would not differ. The query optimization code will check for the potentially best solution anyway in which order of statements can be changed....

View Article


Comment by Norbert on Golang: how to spin up a process with arbitrary...

From the go code there is no visible reason to be flaky. Can you add a sample of a not flaky and a flaky command string?

View Article


Comment by Norbert on Read Google Cloud Pubsub message and write to BigQuery...

I think you might have a good question however the way it is structured right now makes it hard to respond: Can you add more of your code so that the type definitions are visible. Also check the editor...

View Article

Comment by Norbert on GCP Cloud Storage - Golang aws sdk2 - Upload file with...

100% certain the key in the file is in the required format and does not contain another :?

View Article

Comment by Norbert on automatically detecting the HSV values for known...

I am thinking along the lines of facial recognition: First scan for the circles and polygons regardless of color, and than classify the results by color. So essentially it would not use color...

View Article


Comment by Norbert on How to execute file created by my program?

You will have the full path to your file. $PATH is a shell parameter, and might not even be present when using exec.

View Article

Comment by Norbert on Get JSON data directly from rows loop without scanning...

rows.Scan is just the name of the function to map the data into the variables you provide and has nothing to do with the json in itself. See go.dev/doc/database/querying for a bit more detailed...

View Article

Comment by Norbert on go tests error "Request validation failed"

Can you add the (relevant parts of the) EnvVars function to the posted code?

View Article


Comment by Norbert on Multithreaded Spring Boot Application leaves MySQL...

To be able to answer on how to get rid of the processes more information is required: How many database connections stay open? What are you using to run the application (Tomcat? Others?). Which driver...

View Article


Comment by Norbert on Visual Studio Code closes my file when I search for new...

Or on mac: Code -> settings

View Article

Comment by Norbert on Force some pods to schedule on the same node

@Novaterata I was a bit short in that "break statement". Essentially what I meant is that with such a solution you are limiting the k8s scaler in doing its work. This is also limited (to a certain...

View Article

Strange behavior or RAND in MariaDB: Single RAND delivers more than 1 result

When running the following query:SELECT productid FROM product WHERE productid=ROUND(RAND()*(SELECT MAX(productid) FROM product));The result should be 0 or 1 results (0 due to data gaps, 1 if a record...

View Article

Answer by Norbert for How to persist latest queues after pod recreation

You might be missing a setting in you volume claim:kind: PersistentVolumeapiVersion: v1metadata: name: amq-pv-claim-local labels: type: localspec: storageClassName: manual...

View Article


Answer by Norbert for use multiple go routines for different operations on mysql

Looking at your code and your question/requirement: Stay in order as the original go channel delivered the data.Staying in sync and still firing off multiple go routines to process the data, could be...

View Article

Answer by Norbert for Why do some channel operations block and some don't

It does not block for the reason that there are 2 channel listeners (firstFunc and secondFunc). These at random order read your message (whichever wakes up first). So the blocking is there, but not...

View Article


Answer by Norbert for how to fill struct values with exec.Command().Output()...

Since the output of a command can be anything (it can be any command), you will have to create mapping code.The assignment in the struct can look like this:ds:=&dateStruct{day: parseDay(out),month:...

View Article

Answer by Norbert for New line delimited input stream written to file

You can for example use the following pattern to read until your termination byte: r := bufio.NewReader(conn) for { yourLine, err := r.ReadBytes(10) ... write your file ... }Similar there is also...

View Article


Answer by Norbert for Why does using multiple ethernet connections slow down...

There can be multiple factors in play:Kernel or benchmark process in general.If you run a profile of your app, which with mln request in 30seconds, is spending not too much application time, you will...

View Article

Answer by Norbert for Docker compose $GOPATH/go.mod exists but should not

In the root of your GOPATH no packages are expected. The expectation is usually to have a subdirectory src/github.com/someproject/somerepo, which is most likely the root cause of the warning

View Article

Answer by Norbert for Problems running protoc with proto_path to generate Gocode

You have to run with a named proto ( so replace the * with your proto filename, should fix it)

View Article

Answer by Norbert for How to get rid off age in days error in JavaScript....

The answer is in how dates are enumerated in javascript. Months are enumerated 0-11, which means that you have to shift the month with 1 to get a decent response.When the date then does not exist: 31st...

View Article


Answer by Norbert for How do I start my android emulator with go?

Any exit status not 0 is an error from the shell. That is not equal to a golang error (the command executed, however the command internally threw an error). This is often the case by lack of...

View Article


Answer by Norbert for single insert statement in transaction

The use of a transaction around a single insert is not the most useful. They are however passing a function fn TxFn which could contain a complex set of (sql) statements making the given structure more...

View Article

Answer by Norbert for Golang docker container doesn't start on Windows Home

The issue is the order of commands (most likely):docker run -d yourcontainer should workSome unrelated advice: This is a rewrite of your docker file (untested).As you notice it is shorter, and uses a...

View Article

Answer by Norbert for InnoDB Select For Update

Yes, collisions can always occur. So using the design pattern:SELECT FOR UPDATE for all the resources in a given transaction first, can prevent or shorten deadlock situations.Suppose the following...

View Article


Answer by Norbert for Unmarshaling nested custom same-type JSON in Go

Given your json, you can do this:type Envelope struct { Some string `json:"some"` Nested json.RawMessage `json:"nested"`}json.RawMessage is a rather hidden gem, and more people seem to go for the...

View Article

Answer by Norbert for Building Go project from Dockerfile says package not in...

Go has a system variable set location for the build location (which is strict). This is either your home directory +go/src/ or the GOPATH.In your case you have to set your GOPATH:ENV GOPATH /myApp

View Article

Answer by Norbert for Go maps - pulling records based off key value. A...

Your measurement of performance contains other elements:if v, ok := itenariesMap[i]; ok { w.WriteHeader(http.StatusOK) fmt.Fprintf(w, utils.PrettyPrint(s.TravelItenariesCSV[v])) // this takes ~500.0µs...

View Article

Answer by Norbert for How to use json tags in anonymously nested struct?

The issue is with the base structure. type s struct { Links struct { Self struct { Href string } } `json:"_links"` }is the correct syntax

View Article



Answer by Norbert for Mutex not locking

You might want to write this a bit different:You start by locking, which is not the most common way to use a lock: Everything is locked unless you unlock it.A more common way is:package mainimport...

View Article

Answer by Norbert for Protobuffers and Golang --- writing out marshal'ed...

Use proto.Marshal/Unmarshal:That way you simulate (closest) to receiving the message while avoiding side effects from other Marshal methods.Alternative: Dump it as []byte and reread it.

View Article

Answer by Norbert for go build command equivalent api

Since go is build with go, the go/internal (https://pkg.go.dev/std see internal) place is where you want to start looking. It is a rabbit hole but contains all the items like environment variables...

View Article

Answer by Norbert for How to return aggregated document from MongoDB in Golang?

The error states that the category is an array instead of just a string.Your current definition:type Post struct { ID primitive.ObjectID `json:"_id" bson:"_id,omitempty"` Title *string `json:"title"...

View Article


Answer by Norbert for How to fix unsupported relations for schema error with...

You are not using the standard gorm.Model for the keys (from the docs):type Model struct { ID uint `gorm:"primaryKey"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt...

View Article

Answer by Norbert for Why the NATS Golang client, if imported increases the...

It is not uncommon that this happens. The code you import is not just the interface, but also all the interface implementation, and dependencies.Golang does not treeshake the imports on usage (would be...

View Article

Answer by Norbert for Go-SQL-Driver causing maria-db CPU utilization very high

The go process in itself should not have any other effect on (any) database as any other language barring better driver implementations for retrieving the row data (cursor implementation of MySQL was...

View Article


Answer by Norbert for Makefile for GoLang Cross Compilation

Not an idiomatic way. Shorter might be possiblego tool dist listGets you all builds.By now just looking for the first 2 lowercase characters of the OS in the list against the ${os}, look for the arch...

View Article


Answer by Norbert for Best patterns for dynamic checks in Go without reflection?

3 directions, not the most straight forward, but they can reduce your check blocks:Method 1: Define your own annotationGolang has annotations in structstype bla struct { t string...

View Article

Answer by Norbert for Golang Getrlimit returns the different value from ulimit

This is per design since 1.19, see https://github.com/golang/go/issues/46279 for the whole discussion.

View Article

Answer by Norbert for Converting A struct to map using generics

While golang has generics, you are trying to make a generic map, which as far as I know will not work: The inferred type has to be one of the types only:E.g. Input 3 different types, the inference for...

View Article

Comment by Norbert on Why doesn't Go have a function to calculate the...

Or use the ~ annotation to write this for all types of integer to have only one function

View Article

Browsing latest articles
Browse All 42 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>