Going with Mattermost!
After the incredible experience I had with folks from Mattermost during Hacktoberfest (don't forget their thoughtful gift as well!), I decided to go with them once again for November.
Literally "going" with them this time, since their server is written in Go (I apologize for my hurtful sense of humor). During Hacktoberfest, I worked on their mobile app, which is written in TypeScript using React Native. However, the issue I got this time was related to their server, and this would be my first time working on a Go project.
Go
With absolutely no prior knowledge of Go, I made the right decision to learn it first. Fortunately, Go was super easy to get your hands on. I was genuinely amazed by the simplicity of it while being able to produce fast and reliable software. A one-hour video was all I needed to understand the basics, and I found myself pausing way less than when I learned Rust ?.
First of all I want to spend some time to appreciate this adorably goofy gopher:
With that out of the way, I love that Go is statically and strongly typed. This is something I recently discussed with a friend: Statically and/or strongly typed languages only require a little more thoughts into your code design, but they can eliminate a huge amount of ambiguity. Plus, similar to Rust, the Go compiler can infer types where possible, which makes the extra thoughts even more trivial.
Some people call Go "the modern C". Now I get why: It performs really well and has the simplicity of C. It supports low-level operations using pointers. But unlike C, it comes with the features you'd expect from a modern language, such as interfaces, slices, maps, etc. Another fascinating feature is goroutine, which is a uniquely simple model to handle parallel executions.
The Mattermost Issue
Turned out I really went out and overboard with learning Go since this was a really simple issue. All I had to do was implementing error handling in a single file.
In the issue they have a section conveniently mentioned that they prefer errors to be either returned or logged. Knowing Mattermost's developer docs well, I quickly found the section about error handling.
The only obstacle I ran into was determining which log level to use. Although it was mentioned in the docs, I still found the definition ambiguous. However, after a quick search within the project, I realized that these functions always use the same log level in other places. This eliminated my doubts.
Since the functions I was working on serves static HTML pages, I also made sure a proper HTTP error code is returned when error occurs like so:
http.Error(w, err.Error(), http.StatusInternalServerError)
That's all the work! I filed the PR and was initially a little worried, since this was my first time working with Go, but it turned out to be fine. The PR was merged just after a minor fix.
Conclusion
Overall, this was a fun and easy issue to work on. I'm glad that I picked it even if it wasn't as challenging as some other issues I've been working on. I'm always happy to learn a new language and this was an perfect excuse for that! And it was kinda awesome to be able to use it right away.
The above is the detailed content of Going with Mattermost!. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

OpenSSL, as an open source library widely used in secure communications, provides encryption algorithms, keys and certificate management functions. However, there are some known security vulnerabilities in its historical version, some of which are extremely harmful. This article will focus on common vulnerabilities and response measures for OpenSSL in Debian systems. DebianOpenSSL known vulnerabilities: OpenSSL has experienced several serious vulnerabilities, such as: Heart Bleeding Vulnerability (CVE-2014-0160): This vulnerability affects OpenSSL 1.0.1 to 1.0.1f and 1.0.2 to 1.0.2 beta versions. An attacker can use this vulnerability to unauthorized read sensitive information on the server, including encryption keys, etc.

The library used for floating-point number operation in Go language introduces how to ensure the accuracy is...

Backend learning path: The exploration journey from front-end to back-end As a back-end beginner who transforms from front-end development, you already have the foundation of nodejs,...

Queue threading problem in Go crawler Colly explores the problem of using the Colly crawler library in Go language, developers often encounter problems with threads and request queues. �...

The difference between string printing in Go language: The difference in the effect of using Println and string() functions is in Go...

Under the BeegoORM framework, how to specify the database associated with the model? Many Beego projects require multiple databases to be operated simultaneously. When using Beego...

The problem of using RedisStream to implement message queues in Go language is using Go language and Redis...

This article introduces a variety of methods and tools to monitor PostgreSQL databases under the Debian system, helping you to fully grasp database performance monitoring. 1. Use PostgreSQL to build-in monitoring view PostgreSQL itself provides multiple views for monitoring database activities: pg_stat_activity: displays database activities in real time, including connections, queries, transactions and other information. pg_stat_replication: Monitors replication status, especially suitable for stream replication clusters. pg_stat_database: Provides database statistics, such as database size, transaction commit/rollback times and other key indicators. 2. Use log analysis tool pgBadg
