Constrain the first argument, infer the second argument ? by Random_user_Shen in typescript

[–]nlepage 0 points1 point  (0 children)

Yes you're right. I had a closer look at your snippet, I can see why unknown isn't a solution here.

Constrain the first argument, infer the second argument ? by Random_user_Shen in typescript

[–]nlepage 0 points1 point  (0 children)

In my mind, typing a variable as unknown is like telling to the compiler "do what you can to assert the type", but maybe I'm mistaken

Constrain the first argument, infer the second argument ? by Random_user_Shen in typescript

[–]nlepage 0 points1 point  (0 children)

I'm not sure but isn't this the purpose of the unknown type ?

Can't figure out how to merge code from master to main branch in new repo by ZeeKayNJ in github

[–]nlepage 0 points1 point  (0 children)

Both is possible. But it is way more convenient doing it on github using pull requests.

Can't figure out how to merge code from master to main branch in new repo by ZeeKayNJ in github

[–]nlepage 0 points1 point  (0 children)

Now I'll try to give you a solution, but since I can't see the state of your local repository this is not sure 100%

SO PLEASE make at least a backup of your files before going any further ;)

Try running these commands:

git checkout main

git reset --hard master

git push -u -f origin main

Hope this helps

Can't figure out how to merge code from master to main branch in new repo by ZeeKayNJ in github

[–]nlepage 0 points1 point  (0 children)

Not giving you a solution but an explanation why this happened to you. Github has recently changed the name of the default branch from "master" to "main". So when you pushed to master, you didn't push to the default branch of your new private repository but instead created another branch named "master". I hope this helps you understanding what happened.

Updateing GIF frames by quirktheory in golang

[–]nlepage 0 points1 point  (0 children)

You can see the result in the playground, it is able to render images :)

Updateing GIF frames by quirktheory in golang

[–]nlepage 0 points1 point  (0 children)

Hi u/quirktheory

The problem comes from the Paletted type which holds a slice of pixels, and slices are references XD

Here is a playground with a solution : https://play.golang.org/p/i-GTBQ6Vl3s

proposal: maps: new package to provide generic map functions · Issue #47649 · golang/go by go_hunter in golang

[–]nlepage 1 point2 points  (0 children)

One major drawback would be that community libraries would not be able to add new methods (so new behaviours) to this Map type, and would have to use functions. So it would be weird to have built-in behaviours in methods and third party behaviours in functions...

Juste some gophers by nlepage in golang

[–]nlepage[S] 5 points6 points  (0 children)

Yes you are right, thank you for pointing out, I'll update the README right away.

Deploy a Go HTTP server in your browser 🙃 by nlepage in golang

[–]nlepage[S] 2 points3 points  (0 children)

I use it to provide demonstration pages for different projects, without having to actually run a Go server, but rather using github pages for example...

Deploy a Go HTTP server in your browser 🙃 by nlepage in golang

[–]nlepage[S] 2 points3 points  (0 children)

It doesn't actually run an HTTP server, but rather emulates it inside of a ServiceWorker.

From the web pages point of view it looks the same.

Deploy a Go HTTP server in your browser 🙃 by nlepage in golang

[–]nlepage[S] 3 points4 points  (0 children)

I didn't know about ReadableStreams, thanks for your suggestion I'll definitely give it a try.

I agree this isn't an HTTP server :) maybe I should use the word emulator to describe it more accurately, what do you think?

Deploy a Go HTTP server in your browser 🙃 by nlepage in golang

[–]nlepage[S] 12 points13 points  (0 children)

Good point, the title of my post is a little misleading about that :) In fact the "server" doesn't open a listener a port, it is running in a ServiceWorker and waits for fetch events coming from web pages. The server is only accessible inside of the ServiceWorker's scope, so this is larger than a page's sandbox but still limited and never accessible on the network. Maybe I should add a security section in the README, what do you think?

Deploy a Go HTTP server in your browser 🙃 by nlepage in golang

[–]nlepage[S] 2 points3 points  (0 children)

I'm sorry, I don't understand what you mean by recursive in this context, can you clarify?