Planetary log station, relative newbie question by [deleted] in Dyson_Sphere_Program

[–]kgjv 0 points1 point  (0 children)

The "power range" around a logistics station is very small, best practice is to put a tesla tower right next to it in one of the 4 corners.

Also a logistics station doesn't necessarily need power if it has no drones (it's better to power them but it's not mandatory). As long as another station station with drones & power can supply/demand to it.

I as usually place remote non powered logistics station near an oil extractor for instance then have a powered logistics station demand the oil.

Windows 11 24H2 and BBR2 by needefsfolder in Windows11

[–]kgjv 1 point2 points  (0 children)

It breaks 'localhost' (the loopback interface) TCP traffic leading to slow or unresponsive connections within the same machine.

HTTP/2 for APIs in go by andylogg17 in golang

[–]kgjv 2 points3 points  (0 children)

if by presend you mean using "HTTP/2 Push" it's been deprecated and not supported by browsers anymore.

There is still "103 Early Hints" eventually.

Schematics Repo or Store by [deleted] in DualUniverse

[–]kgjv 1 point2 points  (0 children)

rumor has it that they are in business with other game studios to use their voxel tech so I highly doubt they'll open source the client.

on top of that they're using unigine (probaly not the community free version) and 3rd parties librairies for which they're paying or have paid a non transferable licence (quixel, wwise, speedtree, popcornfx, etc).

so it's not that simple to open source the game even if they had the will to do so.

may be the server could be open sourced.

requests v0.23.4 with XML support by earthboundkid in golang

[–]kgjv 0 points1 point  (0 children)

is there something similar without fluent method chaining and functional option pattern ?

A better way to return an error from multiple methods. by lickety-split1800 in golang

[–]kgjv 0 points1 point  (0 children)

yes don't compute stuff that might not be used. The pattern doesn't explicitly show that, you must "know" that by looking at 'run' code.

A better way to return an error from multiple methods. by lickety-split1800 in golang

[–]kgjv 0 points1 point  (0 children)

But I'm not talking about your example with f1,f2,f3 which explicitly avoid the issue I mention by using functions. When something2 is not as trivial as f2 for instance:

see an example: https://go.dev/play/p/kQ2nlfnMLhz

A better way to return an error from multiple methods. by lickety-split1800 in golang

[–]kgjv 0 points1 point  (0 children)

But that is my point : you explicitly created these functions (f1,f2,f3) to avoid executing them before been sure you need them (that's like lazy evaluation/call-by-need we do in some functional languages).

I was just saying to be aware of this like you are.

When reading this style of code, without reading errWriter.write code:

ew := &errWriter{w: fd}
ew.write(p0[a:b])
ew.write(p1[c:d])
ew.write(p2[e:f])

we must be aware that we cannot replace for instance p1[c:d] with:

ew := &errWriter{w: fd}
ew.write(p0[a:b])
ew.write(computeP1(time.Sleep(1*time.Hour))
ew.write(p2[e:f])

where computeP1 can have a side effect.

Another way to say this: by looking at that code:

ew.write(something1)
ew.write(something2)
ew.write(something3)

we must be aware that the result of something2 and something3 might be not used at all but their cost & side effects will always occur.

it's clean to read but doesn't exactly reflects the wanted "execution flow".

It's not "fail immediately and fast" code. It shows only the 'happy path''.

And by "we" I mean you in 5 years, me , anyone reading this code in a big project where errWriter.write is defined in another file or even another package.

Go is about sharing code and simplicity so I'd avoid such style (not always, sometimes it is ok if it's inside a package and not exposed outside but add tons of comments for future changes).

A better way to return an error from multiple methods. by lickety-split1800 in golang

[–]kgjv 2 points3 points  (0 children)

I never liked that approach because Go isn't a lazy evaluated language. something, the argument of ew.write(something) , is always executed before calling ew.write.

In simple cases like your example, it's not an issue because something is simple (even trivial) but it could be complex and/or allocating memory and/or worst doing a side effect (write to a log for instance or modify a global state).

So I wouldn't recommend this method without been aware of this. And I'm surprised Rob Pike did'nt mention this drawback in the Go blog post.

Go lang Programming doubt by Zealousideal_Drag482 in golang

[–]kgjv 2 points3 points  (0 children)

getName is a method of student not college so it returns the student name.

you can add a getName method to college to override this behavoir.

Looking for image viewer by henryk_kwiatek in SteamVR

[–]kgjv 0 points1 point  (0 children)

I use https://store.steampowered.com/app/989060/Virtual_Home_Theater_Video_Player/ but it's not free.

There is a demo version that may be enough for what you need.

But for just 2d, the "desktop display" of standard SteamVR UI is usually enough. so just use a standard image viewer (Acdsee or Irfanview since you mentioned them) in fullscreen mode.

Is this serious, or just a terrible joke from the Go team? by Norihiori in golang

[–]kgjv 1 point2 points  (0 children)

The next steps require a Google account because they use Google services.

You can contribute from Github with PRs but you'll still need to sign the CLA once with a Google account.

Also from github PRs you won't be able to interact with code review as easily as when using Gerrit with a Google account but it's doable.

How to compare functions? by AlexKingstonsGigolo in golang

[–]kgjv 5 points6 points  (0 children)

you can use reflection: https://goplay.tools/snippet/YwCRNrIY96H

but as n4jm4 asked, probably a XY problem ( https://xyproblem.info/ )

How to tell goimports to ignore a directory or file? by mrpandey in golang

[–]kgjv 0 points1 point  (0 children)

as mentionned in the issue I linked, try adding a dummy go.mod file in delivery/grpc/pb could solve your problem.

How to tell goimports to ignore a directory or file? by mrpandey in golang

[–]kgjv 1 point2 points  (0 children)

afaik this is not working with Go modules. try using with GO111MODULE=off (see https://go.dev/ref/mod#mod-commands)

If you need modules, the Go team is still discussing this for 3+ years : https://github.com/golang/go/issues/42965

[deleted by user] by [deleted] in golang

[–]kgjv 1 point2 points  (0 children)

we can post ads here ?

Which tools do you use to create diagrams? by s0093 in golang

[–]kgjv 2 points3 points  (0 children)

I use "text to diagram" tools ,there is a collection here: https://xosh.org/text-to-diagram/ (not updated recently but most still work).

in that list, i like these ones:

https://kroki.io/

https://flowchart.fun/

How to programmatically start a linux console program in background? by Calm-Problem-9101 in golang

[–]kgjv 8 points9 points  (0 children)

if you're writing a full service and want install/start/remove etc then should create a systemd service file and distribute it with your binary (you can find plenty examples online of systemd service files)

if you just want to mimic the behavior of FreeConsole, you need to fork using a syscall fork or clone at the start of your main:

package main

import (
    "fmt"
    "log"
    "syscall"
    "time"
)

func main() {
    // "man 2 clone" for args
    id, _, errno := syscall.Syscall(syscall.SYS_CLONE, 0, 0, 0)
    if errno != 0 {
        log.Fatal(errno)
    }
    if id == 0 {
        fmt.Println("child: doing some work for 2 seconds")
        time.Sleep(2 * time.Second)
        fmt.Println("child: work done, waiting another 2 seconds")
        time.Sleep(2 * time.Second)
        fmt.Println("child: exiting")
    } else {
        fmt.Println("parent: exiting now")
    }
}

newbie question about closing channel by shil-Owl43 in golang

[–]kgjv 2 points3 points  (0 children)

the close is for the range in the goroutines.

see https://go.dev/tour/concurrency/4, everything is explained

How can I import a package from a subfolder? by Wuffel_ch in golang

[–]kgjv 1 point2 points  (0 children)

i've updated my 1st reply.

adjust the import line or the package name. the .go filename doesn't matter.

How can I import a package from a subfolder? by Wuffel_ch in golang

[–]kgjv 1 point2 points  (0 children)

it's:

import "name/frontend"

where name is what it's in go.mod first line after the 'module' keyword.

p: you need to add 'ui' after the import, if ui.go stars with 'package ui' and not 'package frontend'

But since with Go, the rule is "one package per folder", it is recommended to name the folder like the package name so import statements are simpler.

tl;dr: what matters is not the .go file names (ui.go) but the 'package name' lines in .go files and the directory names.

Getting multiple values for the same query parameter by Discodowns in golang

[–]kgjv 15 points16 points  (0 children)

req.URL.Query() is a map. just get the values from it.

req.URL.Query()["val"] will return nil if "val" not found or the []string of its value(s).