今日已更新 80 条资讯 | 累计 20052 条内容
关于我们

标签:#cheatsheet

找到 3 篇相关文章

AI 资讯

Go 1.26 Cheat Sheet

This cheat sheet is based on Go 1.26. Table of Contents Program structure Variables, constants, and types Control flow Functions Arrays, slices, and maps Structs, methods, and tags Interfaces Errors Goroutines, channels, and synchronization Context Generics Iterators Testing Standard-library quick reference Tips and common mistakes Modules and packages Further reading Program structure package main // Every executable must be in package main. import ( "fmt" "os" ) func main () { fmt . Println ( "Hello, Go 1.26" ) os . Exit ( 0 ) } Every Go source file starts with a package declaration. An executable program uses package main and a main function. Group standard-library and third-party imports separately. Variables, constants, and types Variable declarations and inference // var can infer the type from an initializer. var name = "Gopher" // string var age int // No initializer: specify a type. Zero value: 0. var id int64 = 42 // Use an explicit type when int is not what you want. // Short declaration: inside functions only. city := "Tokyo" // Declare multiple variables in a block. var ( x , y int = 1 , 2 msg string ) Use var name = "Gopher" when an initializer makes the type clear. Without an initializer, write the type explicitly. A := declaration is only valid inside a function, and at least one name on its left side must be new. Types and zero values Category Types Zero value Numbers integers, floats, complex numbers 0 ( 0 + 0i for complex) Strings string "" Booleans bool false Arrays [N]T every element is T 's zero value Structs struct every field has its zero value Reference-containing types pointers, slices, maps, channels, functions, interfaces nil Defined types e.g. type UserID int the underlying type's zero value Category Types Notes Boolean bool true or false String string immutable sequence of bytes (usually UTF-8, but invalid UTF-8 is allowed) Signed integers int , int8 , int16 , int32 , int64 int is platform-sized (32 or 64 bit) Unsigned integers uint , u

2026-06-23 原文 →
开发者

WSL 2: Die wichtigsten Befehle für deinen Entwickler-Alltag (Cheatsheet)

Wer täglich in anspruchsvollen Agenturprojekten arbeitet und zwischen Windows-Host und Linux-Umgebung wechselt, weiß: WSL 2 ist ein Gamechanger. Doch selbst wenn man das perfekte Setup einmal konfiguriert hat, kommt unweigerlich der Moment, in dem eine Distribution hängt, RAM freigegeben werden muss oder man ein Backup ziehen will. Anstatt jedes Mal Stack Overflow zu durchsuchen, habe ich mir angewöhnt, die essenziellen Konsolen-Befehle immer griffbereit zu haben. Hier sind die 5 WSL-Befehle, die ich in meinem Setup am häufigsten brauche: Wer täglich in anspruchsvollen Agenturprojekten arbeitet und zwischen Windows-Host und Linux-Umgebung wechselt, weiß: WSL 2 ist ein Gamechanger. Doch selbst wenn man das perfekte Setup einmal konfiguriert hat, kommt unweigerlich der Moment, in dem eine Distribution hängt, RAM freigegeben werden muss oder man ein Backup ziehen will. Anstatt jedes Mal Stack Overflow zu durchsuchen, habe ich mir angewöhnt, die essenziellen Konsolen-Befehle immer griffbereit zu haben. Hier sind die 5 WSL-Befehle, die ich in meinem Setup am häufigsten brauche: 1. Den Status aller Distributionen prüfen Der absolute Standard-Befehl, um zu sehen, welche Linux-Instanzen laufen und welche WSL-Version sie nutzen. wsl --list --verbose # oder kurz: wsl -l -v 2. Der Notaus-Schalter (RAM freigeben) Wenn Docker oder ein Node-Prozess im Hintergrund den gesamten Arbeitsspeicher blockieren, fährt dieser Befehl alle WSL 2 Instanzen sauber herunter. wsl --shutdown 3. Eine bestimmte Distribution als Standard setzen Wichtig, wenn man beispielsweise neben Ubuntu noch Debian installiert hat und festlegen will, was sich beim reinen Befehl wsl öffnet. wsl --set-default <Distributionsname> 4. Die WSL-Umgebung neustarten Es gibt keinen direkten "Restart"-Befehl. Die sauberste Lösung ist das Beenden (Terminate) der spezifischen Instanz. Beim nächsten Aufruf startet sie frisch. wsl --terminate <Distributionsname> 5. IP-Adresse der WSL-Instanz herausfinden Extrem hilfreich für be

2026-06-03 原文 →
AI 资讯

known_hosts

1. Introduction As the golden standard of secure remote access , the Secure Shell (SSH) protocol has several layers of protection. One of them involves recording and keeping track of the known servers on the client side. known_hosts By default, the known_hosts file for a given user is located at: cat /home/user_name/.ssh/known_hosts github.com ssh-rsa *** github.com ecdsa-sha2-nistp256 *** github.com ssh-ed25519 *** Basically, the file contains a list with several columns, separated by whitespace: Identifying host data Host key type Host key value Optional comment The first column can be hashed or cleartext, depending on the setting of HashKnownHosts in /etc/ssh/ssh_config . When hashed, the first field of each line starts with |1| , a HASH_MAGIC marker. After the latter, the field continues with a random 160-bit string, otherwise known as a salt, followed by a 160-bit SHA1 hash. Each of these is encoded in base64 . The main idea is to hide the IP address or hostname data, which would otherwise be directly visible Either way, known_hosts contains a mapping between a server as identified by its characteristics and its key . ## Known Hosts Checking When connecting to a remote host, SSH checks the known_hosts file of the client to confirm the address or hostname for the server match the key we get from it . If there is a match, the session setup can continue. Otherwise, we get an error. The entry for 192.168.6.66 in the known_hosts file doesn’t match the (Elliptic Curve Digital Signature Algorithm, ECDSA ) key we got back from the server at that address . Critically, if we don’t know what caused the error, we should heed the text in capital letters: something nasty can indeed be happening . On the other hand, the reasons for such an issue can be valid and trivial: dynamic IP address changed hostname reinstalled system reinstalled SSH Docker container misconfigured DHCP relocated client In fact, there can be many more. ## Bypass Known Hosts The error text when connectin

2026-06-01 原文 →