<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Go on seth-shi</title><link>https://sethix.com/tags/go/</link><description>Recent content in Go on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 08 Oct 2025 13:36:17 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/go/index.xml" rel="self" type="application/rss+xml"/><item><title>A Zero-Dependency, Multi-Language, Multi-Currency, Multi-Tenant Apple Refund Management Assistant</title><link>https://sethix.com/posts/2025100813-en/</link><pubDate>Wed, 08 Oct 2025 13:36:17 +0800</pubDate><guid>https://sethix.com/posts/2025100813-en/</guid><description>Open Source Github: https://github.com/seth-shi/apple-refund-assistant Overview This service is built on Laravel / Filament multi-tenant architecture, effectively helping developers prevent fraudulent refunds by instantly processing Apple&amp;rsquo;s CONSUMPTION_REQUEST notifications and asynchronously returning consumption data.
Multi-tenant Support Multi-language Support (中文 / English / Español / हिन्दी / العربية / Português / Русский / 日本語 / Français) Multi-currency Support Zero Dependency File+SQLite or upgrade to Redis+MySQL 100% Test Coverage Self-hosted App Keys Private keys are only stored in your database apps table (symmetric encryption, key generated by your application) 12 Consumption Fields - Calculate all required Apple fields Notification Message Forwarding Apple servers send to current service, current service forwards to your production server Online Demo 🌐 Demo URL: https://apple-refund-assistant.</description></item><item><title>Why Can otel.GetTracerProvider() Followed by otel.SetTracerProvider() Still Report Successfully in Go Tracing?</title><link>https://sethix.com/posts/2024092311/</link><pubDate>Mon, 23 Sep 2024 11:14:49 +0800</pubDate><guid>https://sethix.com/posts/2024092311/</guid><description>Recently, when integrating internal tracing in go-zero using some third-party packages, part of the code is as follows: package main import ( &amp;#34;fmt&amp;#34; &amp;#34;github.com/zeromicro/go-zero/zrpc&amp;#34; ) func main() { // 1. Get service configuration svcCtx := svc.NewServiceContext() // 2. Initialize server (this actually calls otel.SetTracerProvider()) // server.NewServer() =&amp;gt; // service.SetUp =&amp;gt; // trace.StartAgent =&amp;gt; // trace.startAgent() =&amp;gt; // otel.SetTracerProvider() s := zrpc.MustNewServer() defer s.Stop() fmt.Printf(&amp;#34;Starting rpc server at %s...\n&amp;#34;, svcCtx.Config.ListenOn) s.Start() } package svc import ( &amp;#34;time&amp;#34; &amp;#34;github.</description></item><item><title>Notes on Writing Tests with go-zero + gorm</title><link>https://sethix.com/posts/2024082617/</link><pubDate>Mon, 26 Aug 2024 17:33:52 +0800</pubDate><guid>https://sethix.com/posts/2024082617/</guid><description>Getting Started Testing Methods &amp;amp; Approaches export_test.go: Used for test data definitions without affecting production code Setup/Teardown patterns: func setUp(testName string) func() { fmt.Printf(&amp;#34;\tsetUp fixture for %s\n&amp;#34;, testName) return func() { fmt.Printf(&amp;#34;\ttearDown fixture for %s\n&amp;#34;, testName) } } func TestFunc1(t *testing.T) { defer setUp(t.Name())() fmt.Printf(&amp;#34;\tExecute test: %s\n&amp;#34;, t.Name()) } func TestMain(m *testing.M) { defer pkgSetUp(&amp;#34;package demo_test&amp;#34;)() m.Run() } Unit Testing
Core business logic in go-zero services (e.g., logic layer) Mock dependencies using: sql-mock for databases redismock for Redis testify-mock for other interfaces Alternative mocking solutions: monkey Integration Testing</description></item><item><title>Integrating SonarQube into Golang Projects for Code Quality Analysis</title><link>https://sethix.com/posts/2024080117/</link><pubDate>Thu, 01 Aug 2024 17:40:53 +0800</pubDate><guid>https://sethix.com/posts/2024080117/</guid><description>Installation and Configuration Installation Binary installation: https://www.sonarsource.com/products/sonarqube/downloads/ Recommended Docker deployment (note volume mounting): https://docs.sonarsource.com/sonarqube/latest/setup-and-upgrade/install-the-server/installing-sonarqube-from-docker/ Install Chinese Pack plugin (optional) 1.png Configure Gitlab Login Documentation: https://docs.sonarsource.com/sonarqube/10.1/instance-administration/authentication/gitlab/
Create application at https://&amp;lt;Your Gitlab URL&amp;gt;/-/profile/applications (read_user permission) Callback URL must be &amp;lt;Your SonarQube URL&amp;gt;/oauth2/callback/gitlab Gitlab login button should appear after configuration
Server base URL must be configured for successful redirection 2.png 3.png 4.png Configure Gitlab project import Create Token at https://&amp;lt;Your Gitlab URL&amp;gt;/-/profile/personal_access_tokens Gitlab API endpoint: https://&amp;lt;Your Gitlab URL&amp;gt;/api/v4 Gitlab option will appear in project creation after successful configuration 5.</description></item><item><title>PHP-roadrunner Stress Testing and Configuration Tuning</title><link>https://sethix.com/posts/2024042417/</link><pubDate>Wed, 24 Apr 2024 17:50:27 +0800</pubDate><guid>https://sethix.com/posts/2024042417/</guid><description>Pod Configuration CPU Memory 0.5 512M Testing Tool Alibaba Cloud PTS Concurrency Duration Source Test Endpoint 100 2 min Public /api/welcome Note: 100 concurrency was determined after initial testing as the maximum load the pod could handle without errors (200 concurrency caused significant RT increases).
Service Startup RoadRunner architecture:
RoadRunner Architecture Laravel Octane natively supports RoadRunner. Start the HTTP service with:
php artisan octane:start --server=roadrunner --host=0.0.0.0 --port=8080 --rpc-port=6001 --workers=1 --log-level=warn --max-requests=50000 --rr-config=/var/www/.</description></item><item><title>Discontinuous Time Segments in Tracing with opentelemetry-auto-laravel in PHP</title><link>https://sethix.com/posts/2024032815/</link><pubDate>Thu, 28 Mar 2024 15:15:29 +0800</pubDate><guid>https://sethix.com/posts/2024032815/</guid><description>The Main Course Time segment issue Found discontinuous time segments when implementing opentelemetry tracing in PHP projects Integration Configuration (Click to expand details) Integration Install extensions (Automatic reporting requires PHP8) https://opentelemetry.io/docs/languages/php/automatic/ opentelemetry extension Container installation: install-php-extensions opentelemetry Windows DLL: https://phpext.phptools.online/extension/php/opentelemetry-261 Composer package: composer install open-telemetry/opentelemetry-auto-laravel Configuration ### Debugging reporting logs OTEL_LOG_LEVEL=debug OTEL_PHP_LOG_DESTINATION=stdout TEL_PHP_AUTOLOAD_ENABLED=true TEL_SERVICE_NAME=test TEL_TRACES_EXPORTER=otlp TEL_METRICS_EXPORTER=none TEL_LOGS_EXPORTER=none TEL_EXPORTER_OTLP_PROTOCOL=grpc TEL_EXPORTER_OTLP_ENDPOINT=http:// TEL_EXPORTER_OTLP_HEADERS=Authentication=xxx TEL_EXPORTER_OTLP_TIMEOUT=1000 TEL_EXPORTER_OTLP_TRACES_TIMEOUT=1000 Implementation open-telemetry/opentelemetry-auto-laravel auto-loads via _register.php in composer.json Default instrumentation: request, cache, log, http client Uses BatchSpanProcessor by default from SDK configuration Sample Code Custom tracer class &amp;lt;?</description></item><item><title>Handling Apple Payment Server Callbacks Like WeChat Pay</title><link>https://sethix.com/posts/2024031416/</link><pubDate>Thu, 14 Mar 2024 16:01:34 +0800</pubDate><guid>https://sethix.com/posts/2024031416/</guid><description>Client-side implementation should use StoreKit2. For server-side notifications, refer to Apple&amp;rsquo;s official documentation.
Database Design (Simplified) # Order Table mysql&amp;gt; desc orders; +------------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+---------------------+------+-----+---------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | no | varchar(255) | NO | UNI | NULL | | | trade_no | varchar(255) | YES | | NULL | | | status | tinyint(4) | NO | | NULL | | | origin_no | varchar(255) | YES | | NULL | | +------------------+---------------------+------+-----+---------+----------------+ # User Subscription Contracts Table mysql&amp;gt; desc member_contracts; +-----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------------+------+-----+---------+-------+ | user_id | bigint(20) unsigned | NO | PRI | NULL | | | status | tinyint(4) | NO | | NULL | | | contract_id | varchar(255) | NO | MUL | NULL | | +-----------------+---------------------+------+-----+---------+-------+ Server-Side Processing Logic Resubscription after expiration changes both appAccountToken and originalTransactionId (after subscription cancellation and expiration) Resubscription during active period retains the same appAccountToken and originalTransactionId Client-Side Order Creation ## Client requests order creation API to generate order number `$uuid` ## Return this value to client for `appAccountToken` usage INSERT INTO orders(no) VALUES(&amp;#39;$uuid&amp;#39;); Subscription Event Callback Handling Apple Server notificationV2 callback &amp;amp;&amp;amp; client-side verification (a JWS string) ## Parse server callback, verify notificationType=SUBSCRIBED and subtype in (INITIAL_BUY, RESUBSCRIBE, AUTO_RENEW_ENABLED) ## Key fields: appAccountToken, transactionId, originalTransactionId, expiresDate ## 1.</description></item><item><title>Building an Ethereum Vanity Address Generator with Distributed Computing Support</title><link>https://sethix.com/posts/2024030713/</link><pubDate>Thu, 07 Mar 2024 13:01:59 +0800</pubDate><guid>https://sethix.com/posts/2024030713/</guid><description>GitHub Repository: https://github.com/seth-shi/ethereum-wallet-generator-worker Full usage tutorial available in project README. Download pre-built binaries for all platforms from releases For Android devices, use Termux to run in background Demo Screenshot Current Progress Estimated 1 week to generate desired vanity address with 0x0000 prefix and 9999 suffix - now running Successfully Generated Address Ethereum Address: 0x0000f31fE398080ef162841Cae9111735C919999 Success Screenshot 1 Success Screenshot 2 Usage Guide Ethereum Vanity Address Generator GitHub: https://github.com/seth-shi/ethereum-wallet-generator-worker Important Notes Generated mnemonics are encrypted in wallet.</description></item><item><title>Automatically Run Top on Secondary Screen at Windows Startup to Monitor Process Usage</title><link>https://sethix.com/posts/2024022015/</link><pubDate>Tue, 20 Feb 2024 15:23:59 +0800</pubDate><guid>https://sethix.com/posts/2024022015/</guid><description>Winget Installation (Choose one method. Using winget facilitates subsequent installations) Preinstalled in Windows 11 Microsoft Store GitHub Release Verify installation: C:\Users\seth-shi&amp;gt;winget --version v1.6.3482 Windows Terminal Install: winget install -e --id Microsoft.WindowsTerminal Configure fullscreen startup as shown: 1.png NTop Install: winget install -e --id gsass1.NTop Launch: ntop -s &amp;quot;mem&amp;quot; (See documentation at https://github.com/gsass1/NTop for more parameters) 2.png Task Scheduler Press Win+R, type taskschd.msc to open Task Scheduler Configuration Create Basic Task Trigger: At system startup Action: Start a program Launch parameters: wt --pos=1000 ntop -s &amp;quot;mem&amp;quot; wt launches Windows Terminal --pos positions window on secondary screen (omit for single display setups) 3.</description></item><item><title>Using gorm gen in go-zero</title><link>https://sethix.com/posts/2023102415/</link><pubDate>Tue, 24 Oct 2023 15:49:25 +0800</pubDate><guid>https://sethix.com/posts/2023102415/</guid><description>Since the built-in sqlx in go-zero is too cumbersome to use, and it&amp;rsquo;s unbearable to write so many magic strings, this article introduces how to integrate gorm into go-zero.
Code Implementation // cmd/gen.go package main import ( &amp;#34;fmt&amp;#34; &amp;#34;path&amp;#34; &amp;#34;gorm.io/driver/mysql&amp;#34; &amp;#34;gorm.io/gen&amp;#34; &amp;#34;gorm.io/gen/field&amp;#34; &amp;#34;gorm.io/gorm&amp;#34; ) var ( // Modify these when generating for other services mysqlDsn = &amp;#34;xxx:xxx@tcp(127.0.0.1:3306)/xxx?charset=utf8mb4&amp;amp;loc=Local&amp;amp;parseTime=true&amp;#34; outPath = path.Join(&amp;#34;..&amp;#34;, &amp;#34;app&amp;#34;, &amp;#34;account&amp;#34;, &amp;#34;model&amp;#34;, &amp;#34;do&amp;#34;) modelPath = &amp;#34;entity&amp;#34; ) func main() { db, err := gorm.</description></item><item><title>Why Are 0.5-Core Pods on k8s So Busy?</title><link>https://sethix.com/posts/2023091320/</link><pubDate>Wed, 13 Sep 2023 20:05:42 +0800</pubDate><guid>https://sethix.com/posts/2023091320/</guid><description>Context Our CTO mentioned during a code review that our services run on 0.5-core Kubernetes pods and advised adjusting runtime parameters. Here&amp;rsquo;s what happened next:
Observation: Our Go services run on pods with 0.5 CPU cores but reported GOMAXPROCS=8 (matching the host machine&amp;rsquo;s 8-core configuration). Problem: This mismatch caused excessive CPU utilization due to thread contention. Solution: Using Uber&amp;rsquo;s automaxprocs to align GOMAXPROCS with the pod&amp;rsquo;s actual CPU limit resolved the issue.</description></item><item><title>Solution for Low Version Redis bitcount Offset Parameter Not Being Bits</title><link>https://sethix.com/posts/2023091221/</link><pubDate>Tue, 12 Sep 2023 21:22:58 +0800</pubDate><guid>https://sethix.com/posts/2023091221/</guid><description>Recently, we needed to implement a &amp;ldquo;check-in for N days to receive gifts&amp;rdquo; feature in a project. This naturally led us to consider using Redis&amp;rsquo; bitmap for implementation. Check-in can be done with setbit {key} {offset} 1 Cumulative check-in days can be retrieved using bitcount {key} {start} {end} index.md
Initially, we implemented it like this: # Base date example: 2023-09-12, offset 0 for this day setbit users:id 0 1 # Binary: 10000000 # Next day, 2023-09-13, offset 1 setbit users:id 1 1 # Binary: 11000000 # Retrieving check-in days from 2023-09-12 to 2023-09-20: bitcount users:id 0 8 # Output: 2.</description></item><item><title>Deploying Monitoring, Log Collection, and Alibaba Cloud ARMS with go-zero</title><link>https://sethix.com/posts/2023083117/</link><pubDate>Thu, 31 Aug 2023 17:50:44 +0800</pubDate><guid>https://sethix.com/posts/2023083117/</guid><description>Official steps from the documentation: https://go-zero.dev/docs/tutorials/monitor/index
Health Checks Name: user-api Host: 0.0.0.0 Port: 8002 DevServer: Enabled: true Port: 6470 HealthPath: &amp;#34;/healthz&amp;#34; Default health check port: 6470, default path: /healthz
You can use Alibaba Cloud&amp;rsquo;s Site Monitoring or similar services to periodically request this endpoint and ensure service availability.
Log Collection Logs can be written to stdout and aggregated using services like Alibaba Cloud SLS. Distributed Tracing Integration with Alibaba Cloud ARMS: https://arms.</description></item><item><title>Personal Single Server Microservices Practice</title><link>https://sethix.com/posts/2023082711/</link><pubDate>Sun, 27 Aug 2023 11:26:42 +0800</pubDate><guid>https://sethix.com/posts/2023082711/</guid><description>Preface Although I started working with microservices last year and deployed them on my personal server, they were all using direct connection mode. Today I took the opportunity to upgrade the go-zero codebase and revamp the architecture. Framework I continued using go-zero (https://github.com/zeromicro/go-zero) which was originally adopted last year, just updating to the latest version.
The code structure features a double-layer service under the root app directory, with shared code in pkg (e.</description></item><item><title>Building APIs Quickly with go-zero and gRPC Gateway</title><link>https://sethix.com/posts/2023081618/</link><pubDate>Wed, 16 Aug 2023 18:51:21 +0800</pubDate><guid>https://sethix.com/posts/2023081618/</guid><description>Official documentation provides a basic introduction. Here we&amp;rsquo;ll cover more advanced implementation details. Advanced Configuration Customizing request paths and methods hello.protobuf file syntax = &amp;#34;proto3&amp;#34;; package hello; option go_package = &amp;#34;./hello&amp;#34;; // Add import import &amp;#34;google/api/annotations.proto&amp;#34;; message Request { } message Response { string msg = 1; } service Hello { rpc Ping(Request) returns(Response) { // Add HTTP option option (google.api.http) = { post: &amp;#34;/api/v1/hello&amp;#34; body: &amp;#34;*&amp;#34; }; } } Update dependencies # Manually download annotations.</description></item><item><title>Implementation of OSS Browser Refresh and Resumable Upload Feature</title><link>https://sethix.com/posts/2023042711/</link><pubDate>Thu, 27 Apr 2023 11:09:55 +0800</pubDate><guid>https://sethix.com/posts/2023042711/</guid><description>Documentation: https://help.aliyun.com/document_detail/383953.html?spm=a2c4g.383947.0.0.47607d9dnkBjdG
Code Implementation &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html lang=&amp;#34;en&amp;#34;&amp;gt; &amp;lt;head&amp;gt; &amp;lt;meta charset=&amp;#34;UTF-8&amp;#34;/&amp;gt; &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt; &amp;lt;/head&amp;gt; &amp;lt;body&amp;gt; &amp;lt;input type=&amp;#34;file&amp;#34; id=&amp;#34;file&amp;#34;&amp;gt; &amp;lt;span id=&amp;#34;process&amp;#34;&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;button id=&amp;#34;submit&amp;#34;&amp;gt;Resume Upload&amp;lt;/button&amp;gt; &amp;lt;!-- Import SDK --&amp;gt; &amp;lt;script type=&amp;#34;text/javascript&amp;#34; src=&amp;#34;https://gosspublic.alicdn.com/aliyun-oss-sdk-6.16.0.min.js&amp;#34; &amp;gt;&amp;lt;/script&amp;gt; &amp;lt;script type=&amp;#34;text/javascript&amp;#34;&amp;gt; // Use multiple clients for multi-file uploads const client = new OSS({ // Replace yourRegion with actual region code region: &amp;#39;yourRegion&amp;#39;, // Get from STS service accessKeyId: &amp;#39;yourAccessKeyId&amp;#39;, accessKeySecret: &amp;#39;yourAccessKeySecret&amp;#39;, stsToken: &amp;#39;yourSecurityToken&amp;#39;, bucket: &amp;#34;examplebucket&amp;#34;, }); // Define checkpoint for resume let abortCheckpoint; // Get DOM elements let uploadFile; const process = document.</description></item><item><title>Upgrading from Flutter 2 to Flutter 3</title><link>https://sethix.com/posts/2023022521/</link><pubDate>Sat, 25 Feb 2023 21:55:31 +0800</pubDate><guid>https://sethix.com/posts/2023022521/</guid><description>Introduction Spent a day upgrading the architecture of Youmengji from Flutter 2 to Flutter 3. Here&amp;rsquo;s a summary of the pitfalls encountered.
Upgrading Flutter Version Check current version:
flutter --version Upgrade Flutter (requires VPN access):
flutter upgrade Verify version (should start with 3.x):
flutter --version If you&amp;rsquo;re lucky enough to run the app directly after this, you can stop reading here.
compileSdkVersion Error Modify compileSdkVersion to 33 in android/app/build.gradle Update distributionUrl in android/gradle/wrapper/gradle-wrapper.</description></item><item><title>Continuous Monthly Subscription - Periodic Deduction - Auto-Renewal Business Process Summary</title><link>https://sethix.com/posts/2022122914/</link><pubDate>Thu, 29 Dec 2022 14:45:32 +0800</pubDate><guid>https://sethix.com/posts/2022122914/</guid><description>Overview The terms &amp;ldquo;Continuous Monthly Subscription&amp;rdquo;, &amp;ldquo;Periodic Deduction&amp;rdquo;, and &amp;ldquo;Auto-Renewal&amp;rdquo; refer to the same core functionality:
Periodic Deduction - Official Alipay terminology Continuous Monthly Subscription - Common implementation pattern (also supports daily/quarterly) Auto-Renewal - User-facing behavior of automatic payment Deduction Scenarios Two implementation models:
Sign-then-Deduct
Redirect to agreement signing page User signs agreement Alipay async callback + immediate deduction Pay-then-Sign
Redirect to payment page (user can disable auto-renewal) User completes payment Receive two async notifications: payment &amp;amp; agreement Recommendation: Prefer Sign-then-Deduct to prevent users from disabling renewal during payment.</description></item><item><title>Using Protobuf Protocol Data in HTTP Requests</title><link>https://sethix.com/posts/2022101211/</link><pubDate>Wed, 12 Oct 2022 11:00:46 +0800</pubDate><guid>https://sethix.com/posts/2022101211/</guid><description>Recently I&amp;rsquo;ve been busy integrating third-party advertising platforms. During this process, I noticed that some API documentation was simply provided as Word documents with hundreds of parameters listed in tables, requiring manual parameter construction - a truly tedious process.
However, several providers stood out by offering .proto files, allowing automatic generation of Request and Response structures through protobuf - a developer-friendly approach worth applauding!
Key Takeaways When integrating APIs, always ask business partners if protobuf schema files are available Generate Go code using: protoc pb\xxx.</description></item><item><title>Does Uploading a 10MB File in Go Really Use 10MB of Memory?</title><link>https://sethix.com/posts/2022070111/</link><pubDate>Fri, 01 Jul 2022 11:45:13 +0800</pubDate><guid>https://sethix.com/posts/2022070111/</guid><description>The short answer: It depends on your configuration and implementation.
Today I saw an interesting question in the community:
Why does PHP handle file uploads using move_uploaded_file to move a pre-uploaded file, rather than reading the file content directly from the HTTP Body?
This question intrigued me. After researching, I found an analysis of PHP file upload implementation (RFC1867) by Laruence (Bird Brother), but it didn&amp;rsquo;t fully explain the reason. So I decided to examine Go&amp;rsquo;s file upload implementation.</description></item><item><title>Service Registration and Discovery in Microservices</title><link>https://sethix.com/posts/2022061518/</link><pubDate>Wed, 15 Jun 2022 18:13:30 +0800</pubDate><guid>https://sethix.com/posts/2022061518/</guid><description>With service registration and discovery mechanisms, consumers don&amp;rsquo;t need to know the actual physical addresses of service providers to make calls, nor do they need to know how many providers are available. Service providers simply register with the registry to expose their services, without needing to know which specific services are consuming them.
RPC Configuration Name: user.rpc ListenOn: 0.0.0.0:8081 Etcd: Hosts: - 127.0.0.1:2379 Key: user.rpc Analyzing the etcd-related source code in go-zero.</description></item><item><title>YouMengji Launched on Google Play</title><link>https://sethix.com/posts/2022041514/</link><pubDate>Fri, 15 Apr 2022 14:41:25 +0800</pubDate><guid>https://sethix.com/posts/2022041514/</guid><description>A side note: The article description was auto-generated using https://copilot.github.com/. This tool is indeed very useful, everyone should give it a try. (The gray text in the image shows its auto-generated suggestions, press Tab to accept them) 1.png Preface In China, except for Huawei AppGallery, other app stores don&amp;rsquo;t allow individual developers to upload applications. Therefore, we decided to publish on Google Play. Initially when developing YouMengji, we didn&amp;rsquo;t consider internationalization and hardcoded all UI text.</description></item><item><title>Using gRPC</title><link>https://sethix.com/posts/2022022518/</link><pubDate>Fri, 25 Feb 2022 18:29:43 +0800</pubDate><guid>https://sethix.com/posts/2022022518/</guid><description>Preface There are many installation tutorials online. Due to updates in gRPC, many commands may become obsolete. This article reflects the current state at the time of writing. If you encounter issues, the best approach is to refer to the official documentation Installation First install Go Install the protoc compiler https://grpc.io/docs/protoc-installation/ The protoc compiler is used to compile .proto files containing service and message definitions Download the zip file matching your OS and architecture (e.</description></item><item><title>Advanced Usage of Pyroscope for Go and PHP Performance Analysis</title><link>https://sethix.com/posts/2022021516/</link><pubDate>Tue, 15 Feb 2022 16:23:40 +0800</pubDate><guid>https://sethix.com/posts/2022021516/</guid><description>Installation Many online tutorials simply use a single Docker command:
docker run -it -p 4040:4040 --restart=always pyroscope/pyroscope:latest server However, this basic installation lacks crucial configurations: no authentication for the data dashboard, no API reporting restrictions (e.g., limiting reporting via API keys), and no data persistence after container destruction. Here&amp;rsquo;s a better approach using docker-compose.yml: version: &amp;#34;3&amp;#34; services: pyroscope: image: &amp;#34;pyroscope/pyroscope:latest&amp;#34; ports: - &amp;#34;4040:4040&amp;#34; command: - &amp;#34;server&amp;#34; environment: ## Enforce API key authentication for data ingestion - PYROSCOPE_AUTH_INGESTION_ENABLED=true ## Enable login for web dashboard - PYROSCOPE_AUTH_INTERNAL_ENABLED=true volumes: ## Persistent data storage - .</description></item><item><title>Building a Message Push Service Bot Using WeCom</title><link>https://sethix.com/posts/2021103013/</link><pubDate>Sat, 30 Oct 2021 13:57:42 +0800</pubDate><guid>https://sethix.com/posts/2021103013/</guid><description>Start Previously, I configured message push notifications on CODING for all successful project deployments. As the number of projects increased and other services required message notifications, the free quota provided by Server Chan became insufficient.
After researching two commonly used services, both have frequency limitations:
Server Chan: Free tier allows only 5 messages/day Qmsg Chan: 30 messages/day with occasional instability Configuration Discovered that Server Chan&amp;rsquo;s documentation teaches how to build a WeCom bot service.</description></item><item><title>Containerizing All Services: Running PHP Code in Containers with Laravel-S</title><link>https://sethix.com/posts/2021102416/</link><pubDate>Sun, 24 Oct 2021 16:05:45 +0800</pubDate><guid>https://sethix.com/posts/2021102416/</guid><description>Preface Recently containerized all Go programs on the server for deployment Combined with CODING&amp;rsquo;s CI/CD, deployment has become extremely pleasant But there were still several PHP projects remaining on the server Blog (Originally built with WordPress) Deploy Nginx and PHP containers, then reverse proxy via host machine Discovered Hugo (similar to Hexo), a static site generator Migrated blog to Hugo with fast builds and real-time previews Now runs in a single Nginx container with host reverse proxy Details: My Blog DreamNote Admin (Laravel) Original Nginx + PHP-FPM container approach Switched to persistent PHP runtime using laravel-s (supports dcat-admin) Official Swoole container docker-swoole with custom Dockerfile: FROM phpswoole/swoole:php7.</description></item><item><title>Analyzing How GoFrame Dynamically Loads Configuration Files and the Invocation of runtime.Caller</title><link>https://sethix.com/posts/2021082518/</link><pubDate>Wed, 25 Aug 2021 18:47:28 +0800</pubDate><guid>https://sethix.com/posts/2021082518/</guid><description>According to the official documentation:
Default Directory Configuration
When initializing the gcfg configuration management object, it automatically adds the following configuration file search directories by default:
Current working directory and its config subdirectory: e.g., /home/www and /home/www/config when working in /home/www Executable file directory and its config subdirectory: e.g., /tmp and /tmp/config for a binary in /tmp Main package directory and its config subdirectory (only effective in source development): e.g., /home/john/workspace/gf-app and /home/john/workspace/gf-app/config for a main package in that directory During development, the configuration file can always be found correctly through the main package location regardless of binary relocation.</description></item><item><title>A Bug When Using defer in Loops in Go</title><link>https://sethix.com/posts/2021081013/</link><pubDate>Tue, 10 Aug 2021 13:47:50 +0800</pubDate><guid>https://sethix.com/posts/2021081013/</guid><description>First note: Using defer inside loops is generally considered a bad practice
Came across this issue while browsing the community: package main import &amp;#34;fmt&amp;#34; type Test struct { name string } func (t *Test) Close() { fmt.Println(t.name, &amp;#34; closed&amp;#34;) } func main() { ts := []Test{{&amp;#34;a&amp;#34;}, {&amp;#34;b&amp;#34;}, {&amp;#34;c&amp;#34;}} for _, t := range ts { defer t.Close() } } // Output: // c closed // c closed // c closed The output shows three c closed results.</description></item><item><title>Differences Between Go and PHP and Parameter Passing in Context</title><link>https://sethix.com/posts/2021010814/</link><pubDate>Fri, 08 Jan 2021 14:55:21 +0800</pubDate><guid>https://sethix.com/posts/2021010814/</guid><description>For developers transitioning from PHP, some common questions arise: How can sequential requests affect each other? In many programming languages, this could be easily achieved using global variables However, in PHP, each request is completely independent This design has both advantages and disadvantages: Downside: Requires reloading code and configurations on each request Advantage: Automatic memory cleanup after request completion eliminates leakage concerns While PHP can achieve cross-request effects using tools like Redis, the approaches differ fundamentally Sample Go Code Analysis package main import ( &amp;#34;fmt&amp;#34; &amp;#34;github.</description></item><item><title>Today Completed Refactoring All Internal APIs from PHP to Go</title><link>https://sethix.com/posts/2021010613/</link><pubDate>Wed, 06 Jan 2021 13:00:27 +0800</pubDate><guid>https://sethix.com/posts/2021010613/</guid><description>Previous API Request Flow User opens APP and requests business API Business API requests recommendation algorithm (with fault tolerance) Recommendation algorithm requests internal service Internal service provides business interface data to recommendation algorithm (e.g., manually configured recommendations) user -&amp;gt; API -&amp;gt; recommend service -&amp;gt; inner service user &amp;lt;- API &amp;lt;- recommend service &amp;lt;- inner service Originally built with Laravel, both API and inner service faced a single-point bottleneck. While API servers could scale horizontally, the inner service remained single-node.</description></item><item><title>Sorting Algorithm - Bucket Sort</title><link>https://sethix.com/posts/2020060709/</link><pubDate>Sun, 07 Jun 2020 09:28:23 +0800</pubDate><guid>https://sethix.com/posts/2020060709/</guid><description>Bucket Sort is well-suited for sorting numbers in the range of 0~100, but its efficiency decreases when dealing with data that has a wide value range.
Algorithm Steps Create n empty buckets based on requirements Traverse the input array to find the maximum and minimum values For each element num, calculate bucket index using formula: floor((num - min) / n) If a bucket already contains elements, maintain elements in sorted order (using linked list) Repeat steps 3-4 until all elements are distributed Concatenate all buckets&amp;rsquo; linked lists and output the sorted array package main import ( &amp;#34;fmt&amp;#34; &amp;#34;math&amp;#34; ) func main() { data := []int{111, 9, 2, 4, 9, 3, 3, 5, 7, 1, 8, 2, 11, 22, 99, 192} fmt.</description></item></channel></rss>