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

标签:#style

找到 19 篇相关文章

AI 资讯

Go Naming: Why Getters Drop the Get Prefix (and Other Idioms)

Book: The Complete Guide to Go Programming Also by me: Hexagonal Architecture in Go — the companion book in the Thinking in Go series My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub You write a Go struct with a private field and a method to read it. Muscle memory from Java, C#, or PHP takes over, and you type GetName() . The code compiles. Tests pass. Then a reviewer leaves a comment that just says "drop the Get" with no explanation, and you're left wondering whether that's a real rule or one person's taste. It's a real rule. It's written into the language's own style guide, the standard library follows it everywhere, and several linters will flag the code that breaks it. Go naming isn't a matter of opinion the way it is in some languages. A handful of conventions are baked into the tooling, and once you know them, half the reviewer nitpicks disappear. Getters drop the Get The convention comes straight from the Effective Go document. If you have an unexported field owner , the accessor is named Owner , not GetName or GetOwner . The mutator, if you need one, keeps the Set prefix. type File struct { owner string } func ( f * File ) Owner () string { return f . owner } func ( f * File ) SetOwner ( o string ) { f . owner = o } The reasoning is about how the call reads. person.Name() says the same thing as GetName() with less noise, and the parentheses already tell you it's a method call. Get adds a word that carries no information in a language where field access and method calls look different anyway. The Set prefix stays because there's no other clean way to signal mutation. Name() reads, SetName(x) writes. The asymmetry is deliberate. This shows up all over the standard library. bytes.Buffer has Len() , not GetLen() . sync.Once has no getters to get wrong, but http.Request exposes fields and methods that never carry a Get . time.Time has Hour() , Minute() , Second() . The pattern is

2026-07-03 原文 →
AI 资讯

Elevate Your Living Space with Data-Driven Interior Design

Most devs spend all day fixing broken layouts in the browser. Why not fix the one in your actual office? I started treating my desk setup like a refactor project. It turns out, you can actually optimize your physical space with some basic data. Measuring the vibe Data-driven design just means using actual inputs to pick your furniture and paint. Don't guess. Measure your natural light exposure or run a quick script to test your color schemes. Color matters. The American Society of Interior Designers claims blues and greens drop stress by 70%. I don't know if that number is perfect, but I switched my wall to a soft sage and feel less fried at 5 PM. If you want to check the dominant colors in your room, use this bit of Python. import numpy as np from PIL import Image def analyze_color_palette ( image_path ): img = Image . open ( image_path ) img = img . convert ( ' RGB ' ) pixels = np . array ( img ) dominant_color = np . mean ( pixels , axis = ( 0 , 1 )) return dominant_color # Example usage: image_path = ' path/to/image.jpg ' dominant_color = analyze_color_palette ( image_path ) print ( dominant_color ) Pathfinding for your chair Furniture layout often feels like a guessing game. You move the desk, hit your knee on the shelf, and move it back. You can treat your room like a graph problem instead. Use Dijkstra’s algorithm to map the walking paths between your printer, desk, and coffee machine. If your path length is high, your layout is bad. class Graph { constructor () { this . vertices = {}; } addVertex ( vertex ) { this . vertices [ vertex ] = {}; } addEdge ( vertex1 , vertex2 ) { this . vertices [ vertex1 ][ vertex2 ] = 1 ; } dijkstra ( start ) { const distances = {}; const previous = {}; for ( const vertex in this . vertices ) { distances [ vertex ] = Infinity ; previous [ vertex ] = null ; } distances [ start ] = 0 ; const queue = [ start ]; while ( queue . length > 0 ) { const vertex = queue . shift (); for ( const neighbor in this . vertices [ vertex ]) { con

2026-06-30 原文 →
AI 资讯

What Western Devs Need to Know Before Visiting China in 2026: Alipay, WeChat Pay & the Mobile Web

If you write software for a living and you're considering a trip to China in 2026, the friction you'll hit is not what you expect. The Great Firewall is the headline, but it's rarely what trips up a first-time visitor. What actually breaks your week is the small stuff: a QR code at a noodle shop, a metro turnstile that won't take your foreign card, a hotel Wi-Fi that quietly drops every request to Google. This is a brief survival guide written from a developer's mindset: what's actually changed in 2026, what you can fix before you leave, and what you should just accept. 1. Visa-free entry now covers most Western devs As of late 2025, China extended its 30-day visa-free transit policy to passport holders from 38 countries, including the US, UK, Germany, France, Australia, the Netherlands, and most of the EU. If you're flying in for a vacation, a conference, or even a short remote-work stretch, you may not need to apply for a visa at all — you just need an onward ticket within 30 days. The catch: the rules per nationality drift quarterly, and the official guidance is scattered across embassy pages. I keep a more current breakdown here: FirstTripChina visa-free guide — worth checking the week you book your ticket. 2. The payment problem is the real "API" you need to integrate China runs on two payment rails: Alipay and WeChat Pay. Cash is technically legal but vendors below the level of a 4-star hotel will look at you like you handed them a stone tablet. Foreign credit cards work at airports and big chains; they do not work at the dumpling place you actually want to eat at. The fix that exists in 2026 — and that did not exist three years ago — is "Tour Card" inside Alipay and "International" mode inside WeChat Pay. Both let you link a Visa/Mastercard issued outside China and pay via the same QR system locals use. Setup steps (roughly): Install Alipay (App Store / Play Store, US/EU regions both work). Verify with passport + selfie (KYC takes about 3 minutes). Tap Tour C

2026-06-23 原文 →