CodeBlooded

joined 1 year ago
[–] CodeBlooded@programming.dev 2 points 2 months ago

Gimp is all I know, I can’t compare to Photoshop, and I love it! ❤️

[–] CodeBlooded@programming.dev 4 points 2 months ago

This sounds wonderful. I played Windows games on Linux for a decade, and it was often a painful experience. I’d love to see some real life in-game comparisons to illustrate what this brings to the table!

[–] CodeBlooded@programming.dev 1 points 2 months ago* (last edited 2 months ago)

Report: Linux was on 6.34 percent of computers last month if you count ChromeOS.

What are the reasons one wouldn’t count ChromeOS? I guess I don’t know much about it, is it somehow “less Linux” than your run of the mill Ubuntu/Debian, Arch, openSUSE, etc?

[–] CodeBlooded@programming.dev 25 points 7 months ago (1 children)

The misconception that we’re the person to go to to fix your printer…

..I mean we probably can fix it, but it’s a waste of our time…

[–] CodeBlooded@programming.dev 2 points 7 months ago

I’m not crazy about Google’s part in Go, but man, I’ve been using Go a lot and I love it. It feels like a “modern C” that lets you focus on logic instead of memory allocation. I know it violates your requirements, but I’d suggest checking it out anyway! 🤷‍♂️

[–] CodeBlooded@programming.dev 22 points 9 months ago* (last edited 9 months ago)

I feel your pain. I once worked at a place that hired an “expert” as a senior dev who asked me on the first day, “what is this import on the first line of this code??? I’ve never seen this before. 🤔” They were unfamiliar with the concept of packages and importing them… Senior dev, hired specifically because they were an expert in a specific language…

They’d call me upwards of 12 times a day for help with the most basic of tasks with anything technical, to include how to install the basic runtime to be able to run code in that language.

(I’m speaking quasi cryptically on purpose.)

[–] CodeBlooded@programming.dev 5 points 1 year ago

This was oddly specific 🤔

[–] CodeBlooded@programming.dev 24 points 1 year ago

As of this last month, Lemmy is my new “go to” for scrolling social media. My Reddit usage is probably 20% or less of what it used to be.

A part of this was Voyager’s Progressive Web App (https://vger.app), it made me feel right at home after Apollo shut down.

[–] CodeBlooded@programming.dev 1 points 1 year ago

I see what you're saying. Hmm. I do think that clear will be a nice addition. It does exactly what it says it'll do, "clear" out the object. In that same vein, I think your suggestions would both be solid alternatives.

It sounds like clear is already on track to become a part of the language, but maybe you could be the first to put in a suggestion for a zero to accompany it in future releases?

[–] CodeBlooded@programming.dev 1 points 1 year ago* (last edited 1 year ago) (2 children)

Are you speaking about clear? It’s my understanding that clear doesn’t get you anything. It modifies the object passed to it, sure, but it doesn’t return different types back to the caller.

Edit: I notice this is downvoted- can someone provide feedback if my understanding of clear is incorrect? 🤔

[–] CodeBlooded@programming.dev 3 points 1 year ago* (last edited 1 year ago)
[–] CodeBlooded@programming.dev 6 points 1 year ago (10 children)

Does your ad blocker block ads for YouTube and YouTube Music apps on iOS?

 

I’ve been using this to execute Go “scripts” in CI pipelines where Bash just doesn’t cut it. It’s an interpreter for Go. It can be used to treat Go code like a “script,” rather than a compiled application. It is also able to be imported into a Go program and used to load up Go code dynamically at run time (think “loading plugins” with Go!).

From the readme:

release Build Status GoDoc

Yaegi is Another Elegant Go Interpreter. It powers executable Go scripts and plugins, in embedded interpreters or interactive shells, on top of the Go runtime.

Features

  • Complete support of Go specification
  • Written in pure Go, using only the standard library
  • Simple interpreter API: New(), Eval(), Use()
  • Works everywhere Go works
  • All Go & runtime resources accessible from script (with control)
  • Security: unsafe and syscall packages neither used nor exported by default
  • Support the latest 2 major releases of Go (Go 1.19 and Go 1.20)

Install

Go package

import "github.com/traefik/yaegi/interp"

Command-line executable

go install github.com/traefik/yaegi/cmd/yaegi@latest

Note that you can use rlwrap (install with your favorite package manager), and alias the yaegi command in alias yaegi='rlwrap yaegi' in your ~/.bashrc, to have history and command line edition.

CI Integration

curl -sfL https://raw.githubusercontent.com/traefik/yaegi/master/install.sh | bash -s -- -b $GOPATH/bin v0.9.0

Usage

As an embedded interpreter

Create an interpreter with New(), run Go code with Eval():

package main

import (
	"github.com/traefik/yaegi/interp"
	"github.com/traefik/yaegi/stdlib"
)

func main() {
	i := interp.New(interp.Options{})

	i.Use(stdlib.Symbols)

	_, err := i.Eval(`import "fmt"`)
	if err != nil {
		panic(err)
	}

	_, err = i.Eval(`fmt.Println("Hello Yaegi")`)
	if err != nil {
		panic(err)
	}
}

Go Playground

As a dynamic extension framework

The following program is compiled ahead of time, except bar() which is interpreted, with the following steps:

  1. use of i.Eval(src) to evaluate the script in the context of interpreter
  2. use of v, err := i.Eval("foo.Bar") to get the symbol from the interpreter context, as a reflect.Value
  3. application of Interface() method and type assertion to convert v into bar, as if it was compiled
package main

import "github.com/traefik/yaegi/interp"

const src = `package foo
func Bar(s string) string { return s + "-Foo" }`

func main() {
	i := interp.New(interp.Options{})

	_, err := i.Eval(src)
	if err != nil {
		panic(err)
	}

	v, err := i.Eval("foo.Bar")
	if err != nil {
		panic(err)
	}

	bar := v.Interface().(func(string) string)

	r := bar("Kung")
	println(r)
}

Go Playground

As a command-line interpreter

The Yaegi command can run an interactive Read-Eval-Print-Loop:

$ yaegi
> 1 + 2
3
> import "fmt"
> fmt.Println("Hello World")
Hello World
>

Note that in interactive mode, all stdlib package are pre-imported, you can use them directly:

$ yaegi
> reflect.TypeOf(time.Date)
: func(int, time.Month, int, int, int, int, int, *time.Location) time.Time
>

Or interpret Go packages, directories or files, including itself:

$ yaegi -syscall -unsafe -unrestricted github.com/traefik/yaegi/cmd/yaegi
>

Or for Go scripting in the shebang line:

$ cat /tmp/test
#!/usr/bin/env yaegi
package main

import "fmt"

func main() {
	fmt.Println("test")
}
$ ls -la /tmp/test
-rwxr-xr-x 1 dow184 dow184 93 Jan  6 13:38 /tmp/test
$ /tmp/test
test

Documentation

Documentation about Yaegi commands and libraries can be found at usual godoc.org.

Limitations

Beside the known bugs which are supposed to be fixed in the short term, there are some limitations not planned to be addressed soon:

  • Assembly files (.s) are not supported.
  • Calling C code is not supported (no virtual "C" package).
  • Directives about the compiler, the linker, or embedding files are not supported.
  • Interfaces to be used from the pre-compiled code can not be added dynamically, as it is required to pre-compile interface wrappers.
  • Representation of types by reflect and printing values using %T may give different results between compiled mode and interpreted mode.
  • Interpreting computation intensive code is likely to remain significantly slower than in compiled mode.

Go modules are not supported yet. Until that, it is necessary to install the source into $GOPATH/src/github.com/traefik/yaegi to pass all the tests.

Contributing

Contributing guide.

License

Apache 2.0.

 

OrbStack is a fast, light, and simple way to run Docker containers and Linux machines on macOS. You can think of it as a supercharged WSL and Docker Desktop alternative, all in one easy-to-use app.

I just caught wind of this and have yet to try it. Does anyone here have any experience with OrbStack that they can speak to? 👀

view more: next ›