26
13
27
-8
#TT (mastodon.social)
28
9

Sometime around the middle of January, I stumbled across One Billion Rows Challenge. I had a lot of fun working on this. I started with an execution time of > 6min and finished at about 14s. Here’s how I went about it.

29
17
30
24
submitted 6 months ago by mac@programming.dev to c/golang@programming.dev
31
1
submitted 6 months ago by codesoap@feddit.de to c/golang@programming.dev

I've seen that a new "range-over-func" experiment is available with Go 1.22. In this article, I took a closer look and evaluated the feature for myself.

32
17
submitted 6 months ago by jwr1@kbin.earth to c/golang@programming.dev
33
6

cross-posted from: https://lemmy.world/post/11504334

ServerClip is a tool for copying contents of a file over various ssh connections. Need to get a log file over to your laptop? This can help.

34
4
submitted 6 months ago by mac@programming.dev to c/golang@programming.dev
35
10
submitted 6 months ago by darkhz@lemm.ee to c/golang@programming.dev

Hello Lemmy,

invidtui is a TUI-based Invidious client, which can:

  • Search for and browse videos, playlists and channels
  • Play audio or video from any instance
  • View, open, edit and save m3u8 playlists
  • Download video/audio in any format
  • Authenticate with the preferred instance, and show user feed, playlists and subscriptions

This release contains the following new features/fixes:


Dynamic theming

Themes can now be applied from theme files dynamically within the application as well as from command-line and configuration options.

A demo and instructions are posted here


Channel 'Releases' tab

A new 'releases' tab is added to the channel page, to show new content from channel authors.


Enhanced configuration handling

Configuration handling is now done in the most cross-platform way as possible.


I hope you enjoy this release, and any feedback is appreciated.

36
12
37
10
submitted 6 months ago by mac@programming.dev to c/golang@programming.dev
38
14

I am doing a lot of work right now that requires day and year durations and I have to define those myself. I wonder why they didn't include those in the time package.

39
10
Coming Soon: Golang 1.22 (www.dolthub.com)
submitted 7 months ago by mac@programming.dev to c/golang@programming.dev
40
11
submitted 7 months ago by mac@programming.dev to c/golang@programming.dev
41
10
submitted 7 months ago by mac@programming.dev to c/golang@programming.dev
42
35
Go: What We Got Right, What We Got Wrong (commandcenter.blogspot.com)
43
8

Repo: https://git.code.netlandish.com/~petersanchez/gohome

I wrote a simple application to easily manage your Go modules that you host on your own domains, backed by sqlite3.

I know there are quite a few ways to do this (nginx hacks, static pages, other server apps) but none of them scratched my itch. I wanted a simple utility that I can add/edit via my web browser and be done with it. No config file changes, no server reloads, etc.

Happy to hear all feedback.

Blog post (if you care): https://petersanchez.com/easily-host-go-modules-on-your-domain/

44
19
submitted 7 months ago by tedu@azorius.net to c/golang@programming.dev

Based on the Go 1.22 release notes from the Go team (3-Clause BSD License), with many interactive examples added. This blog post is synchronized with the source document as it gets updated.

45
1
submitted 7 months ago by darkhz@lemm.ee to c/golang@programming.dev

Hello Lemmy,

invidtui is a TUI-based Invidious client, which can:

  • Search for and browse videos, playlists and channels
  • Play audio or video from any instance
  • View, open, edit and save m3u8 playlists
  • Download video/audio in any format
  • Authenticate with the preferred instance, and show user feed, playlists and subscriptions

A new demo video has been uploaded here.

This release contains the following new features/fixes:


Redesigned Media Queue

The queue is now completely managed by invidtui, with MPV being used only for playback. This change resulted in a big reduction in CPU usage, especially when loading large playlists.

  • Shuffle mode is on-demand, with a focus on not playing the same item more than once in a single cycle.
  • Media statuses (fetching/loading/playing) are shown for the currently selected item
  • Dynamic audio/video switching of any item in the queue
  • Media items are fetched from the selected instance, and can be reloaded as the instance is changed.

Media Fetcher

The new media fetcher will show statuses of each added media item, and allow for viewing any errors and performing reload/cancel actions on each or all media items being added.


Playlist/Player Improvements

Playlists are now downloaded faster, and are generated in the proper M3U8 format. The player also shows media statuses, as well as the buffering percentage of the current media.

Note that playlists may have to be regenerated/redownloaded if they were previously generated by older versions.


I hope you enjoy this release, and any feedback is appreciated.

46
10
submitted 8 months ago by 111000@reddthat.com to c/golang@programming.dev
47
8

Hi 👋

I have tried to learn some go but I am still very much at the beginning, like understanding how to work with variables and functions. My background is mostly in python but I am not a programmer by trade.

package main

import (
	"crypto/sha256"
	"fmt"
	"io"
	"log"
	"os"
	"path/filepath"
)

func write_lines_to_file(lines []string, output_file string) {
	f, err2 := os.Create(output_file)
	if err2 != nil {
		log.Fatal(err2)
	}
	defer f.Close()
	for _, line := range lines {
		_, err := f.WriteString(line + "\n")
		if err != nil {
			log.Fatal(err2)
		}
	}
}

func get_size_and_hash(file_path string) (int, string) {
	file, err := os.Open(file_path)
	if err != nil {
		panic(err)
	}
	defer file.Close()
	hash := sha256.New()
	if _, err := io.Copy(hash, file); err != nil {
		panic(err)
	}
	sum := fmt.Sprintf("%x", hash.Sum(nil))
	file, err2 := os.Open(file_path)
	if err2 != nil {
		log.Fatal(err2)
	}
	fi, err2 := file.Stat()
	if err != nil {
		log.Fatal(err2)
	}
	my_size := fi.Size()
	return int(my_size), string(sum)
}

func get_list_of_files(target_directory string) []string {
	var files []string
	err := filepath.Walk(target_directory, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			fmt.Println(err)
			return nil
		}
		if !info.IsDir() {
			files = append(files, path)
		}
		return nil
	})
	if err != nil {
		log.Fatal(err)
	}
	return files
}

func main() {
	// accept directory as user input
	target_directory := os.Args[1]

	my_files := get_list_of_files(target_directory)

	var content []string

	for _, file := range my_files {
		size, hash := get_size_and_hash(file)
		var str_file string = string(file)
		str_size := fmt.Sprint(size)
		var str_hash string = string(hash)
		// structure: file, checksum, size
		combined_line := str_file + "," + str_hash + "," + str_size
		content = append(content, combined_line)
	}

	var output_file string = target_directory + "/PULP_MANIFEST"
	write_lines_to_file(content, output_file)
}

I am testing this using the following command: rm -f test_input/PULP_MANIFEST && go fmt pulp_manifest.go && go build pulp_manifest.go && ./pulp_manifest test_input && cat test_input/PULP_MANIFEST on Fedora with go 1.20

Known Limitations

  • My rewrite does not handle files or directories with "," yet.

Untested

  • Files with binary content
  • Paths on macOS or Microsoft Windows
  • Paths with whitespace
  • Symlinks in target_directory
  • target_directory as symlink

I am looking for the following feedback:

  • bugs and limitations
  • a was to add tests: do you have any recommendations for talks or blog posts?
  • style & best practice
  • a way to use static typing?!
  • anything else that you would recommend a novice.

Right now, I believe my rewrite works. Feel free to shatter my assumption. Cheers.

48
5
submitted 8 months ago* (last edited 8 months ago) by mac@programming.dev to c/golang@programming.dev

Not OC

49
12
submitted 8 months ago by mac@programming.dev to c/golang@programming.dev
50
10
view more: ‹ prev next ›

Golang

1707 readers
3 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 1 year ago
MODERATORS