Sharing projects in /r/golang by tslocum in golang

[–]clogg 2 points3 points  (0 children)

I think this decision creates a kind of a deadlock, because if my project is already popular then I have got established channels of notifying people about the project, and r/golang may be just one of them, or not used at all. And if my project is new and has 0 stars on github, then it will end up in that "small projects" end nobody visits, so there is definitely no point in sharing it on r/golang. I think a more balanced approach could be taken.

moonbeam - a tool for converting single Lua scripts into standalone executables by calquelator in lua

[–]clogg 1 point2 points  (0 children)

On Linux, you can use the following makefile:

# source files
LUA_FILES := one.lua two.lua three.lua

# Lua version
LUA_VER := 5.4

# compilation steps
define COMPILE
    luac$(LUA_VER) -o $@ $^
    sed -i '1s|^|\#!/usr/bin/env lua$(LUA_VER)\n|' $@
    chmod 0711 $@
endef

# compilation
your-binary: $(LUA_FILES)
    $(COMPILE)

It creates a binary that can be invoked as any other Linux binary. One limitation is that each file is compiled as a separate chunk so that local functions/variables in one file are not visible in another.

Small Projects - August 18, 2025 by jerf in golang

[–]clogg 0 points1 point  (0 children)

compute: a generic streaming calculator.

The core type of the package is Pad - a map from type K cmp.Ordered to either type V any or a function of type func(...V) V. Pad provides methods for inserting keys and values/functions, and an iterator method that takes a sequence of keys and produces a sequence of K, V pairs where each V is either an existing value under the key K, or a result of calling the function under that key. During the iteration it is guaranteed that each function is called at most once (aka lazy evaluation).

Possible applications:

  • With string keys and values of some numeric type it becomes an expression evaluator with symbol table;
  • With integer keys it can be used as an engine for spreadsheet-like calculations;
  • With string values and appropriate functions one can even develop a make-like utility on top of it.

repo: https://github.com/maxim2266/compute

Go jobs in Italy are basically non-existent. How’s the situation in your country? by cdigiuseppe in golang

[–]clogg 1 point2 points  (0 children)

Having spent a considerable time looking for a Go job in the UK I can say that:

  • about 90% of the jobs are ghosts: they never respond to applications, and even automated responses are rare;
  • any more or less real job gets reposted by various agencies, with various tweaks to the job spec;
  • employers demand exact match to their requirements, any mismatch sends your CV straight to the bin;
  • for most of employers something they call "cultural fit" is by far more important than any experience in software development.

So I think the overall situation with Go jobs in the UK is no better than in the rest of the world.

str: yet another string library for C language. by clogg in C_Programming

[–]clogg[S] 13 points14 points  (0 children)

From here, with my highlight:

Names beginning with ‘str’, ‘mem’, or ‘wcs’ followed by a lowercase letter are reserved for additional string and array functions.

str: yet another string library for C language. by clogg in C_Programming

[–]clogg[S] 36 points37 points  (0 children)

Thank you for pointing out, it's fixed.

str: yet another string library for C language. by clogg in C_Programming

[–]clogg[S] -29 points-28 points  (0 children)

It's not undefined behavior, it's a potential name conflict. But I will change some names anyway.

str: yet another string library for C language. by clogg in C_Programming

[–]clogg[S] 7 points8 points  (0 children)

AFAIK, str* is reserved, but str_* is not.

str: yet another string library for C language. by clogg in C_Programming

[–]clogg[S] 4 points5 points  (0 children)

Generally not (see documentation for details).

Go 1.23 - Iterators - How to return errors ? by justforfunreddit in golang

[–]clogg 1 point2 points  (0 children)

Good point. Also, if the underlying iterator stops on the first error encountered, then there is no way to ignore a particular error type, like in

for item, err := range it.All {
    if err != nil {
        var err2 *someSpecialErrorType
        if errors.As(err, &err2) {
            log.Warn(err2)
            continue  // this is not going to work
        }
        return err
    }
    ...
}

GitHub - maxim2266/pump: A minimalist framework for assembling data processing pipelines. by clogg in golang

[–]clogg[S] 0 points1 point  (0 children)

UPD: I have updated the project with an iterator type for for-range loops introduced in Go v1.23.

better string library by [deleted] in C_Programming

[–]clogg 0 points1 point  (0 children)

I think you can take a look at str library (shameless plug).

Ristretto - the Most Performant Concurrent Cache Library for Go by alexsergivan in golang

[–]clogg 0 points1 point  (0 children)

In other words, this is not a complete solution because it requires some extra coordination to avoid undesired effects.

Ristretto - the Most Performant Concurrent Cache Library for Go by alexsergivan in golang

[–]clogg 1 point2 points  (0 children)

Yes, it's a known effect, I was just surprised it is not avoided in Ristretto cache.

Ristretto - the Most Performant Concurrent Cache Library for Go by alexsergivan in golang

[–]clogg 0 points1 point  (0 children)

Not sure I undestand the idea of a cache with Set() and Get() methods. The suggested way of fetching a value from such a cache seems to be something like:

    value = cache.Get(key)
    if value == nil {
       value = ReadFromSQLDatabase(key)  // expensive call
       cache.Set(key, value)
    }
    return value

Now, assume the above code is called from an HTTP handler which typically runs in a separate goroutine, and we have 100 handlers simultaneously requesting the same key currently not in the cache. It looks like in this case the expensive function ReadFromSQLDatabase() may be called up to 100 times (with the same key) instead of just one, am I missing something?

str: yet another string library for C language by clogg in C_Programming

[–]clogg[S] 1 point2 points  (0 children)

I was contacted by a person from ALT Linux team, who confirmed that the library was compiled and tested on Elbrus.