2. Handling HTTP Requests with Gin – HTML Templates

2.6 HTML Templates Go language uses the built-in <span>html/template</span> package to render HTML templates, providing safe template parsing and execution features to prevent cross-site scripting attacks (XSS). Templates can be created using <span>template.New()</span> and then read and parsed using <span>ParseFiles()</span>. Gin uses the <span>gin.Context</span> object’s <span>HTML()</span> method to combine HTML templates with data, rendering and … Read more

Practical Use of Go Language httptest: Making HTTP Testing as Easy as Drinking Water

In daily development, we often need to write HTTP-related code, but testing this code can be quite a headache. Traditional testing methods require starting a real server, configuring ports, and cleaning up resources after testing, making the process cumbersome and error-prone. The <span>httptest</span> package in the Go standard library provides us with an elegant solution. … Read more

Fearless Against Anti-Scraping? This Open Source HTTP Client Stands Strong!

Fearless Against Anti-Scraping? This Open Source HTTP Client Stands Strong!

Hello everyone, I am Octopus Cat. Those who have worked with web scraping know that the HTTP request step is often the “key to success or failure”. If you are just requesting some public APIs, Go’s net/http standard library is completely sufficient. However, once you encounter websites with anti-scraping detection, the situation becomes complicated: Some … Read more

Go Language Learning Notes (Twenty-Nine) Assembly Functions

Go Language Learning Notes (Twenty-Nine) Assembly Functions

1. Basic Usage:The function identifier is defined using the TEXT assembly directive, indicating that the instructions starting from this line are defined in the TEXT memory segment. The instructions following the TEXT statement generally correspond to the implementation of the function. However, the TEXT directive itself does not concern whether there are instructions following it. … Read more

Understanding the C Language: Its Functions and Differences from Go Language

Understanding the C Language: Its Functions and Differences from Go Language

In this article, we introduce another language in computing: C Language; what are its differences from Go Language? What are its applications? Let’s take a look! Introduction The C language was born in 1972-1973 and is a general-purpose programming language that is “close to hardware, highly efficient, and deeply influential”; its role is not only … Read more

Weekly Library | Chi: An Elegant HTTP Router Library for Go

Weekly Library | Chi: An Elegant HTTP Router Library for Go

Weekly Library | Chi: 🚦 An Elegant HTTP Router Library for Go When building web services and APIs, an excellent routing library can greatly enhance development efficiency. Chi, with its lightweight design and powerful features, has become a highly regarded HTTP routing solution in the Go language ecosystem. 💡 Understanding Chi Chi is a lightweight … Read more

Goodbye, Python. Hello, Go Language

Goodbye, Python. Hello, Go Language

Let me explain the title of this article. 1. Both Python and Go are excellent programming languages, each excelling in different areas. Python is more mature, has a wealth of libraries, and is suitable for scripting and data analysis, dominating the field of artificial intelligence. Go, being relatively young, is more vibrant and excels in … Read more

Go Language Static Resource Service: HTTP Cache Control and ETag Validation Mechanism

Go Language Static Resource Service: HTTP Cache Control and ETag Validation Mechanism

Click the above“blue text” to follow us “Encountering this problem again?” When images on the website load slowly, users start complaining, and the operations team looks confused at the server monitoring. This scene is too familiar, right? In fact, this may be due to improper caching of static resources. In Go language development, correctly implementing … Read more

Go Language: HTTP Middleware Chain – CAS Operation Principles and Dynamic Dispatch Efficiency Improvement

Go Language: HTTP Middleware Chain - CAS Operation Principles and Dynamic Dispatch Efficiency Improvement

Click the “blue text” above to follow us Yesterday, my friend Xiao Li called me: “Brother Feng, help! Our API service always lags during peak times, and I suspect it’s a middleware issue.” I laughed; isn’t this an old story? No matter how fancy the code is, it can’t escape the performance hurdle. Especially in … Read more