Table of Contents
Why did we Go with Go?
mgo

Go Agent, Go

Jun 07, 2016 pm 04:30 PM
agent Hacker news

Discuss on Hacker News 10gen introduced MongoDB Backup Service in early May. Creating a backup service for MongoDB was a new challenge, and we used the opportunity to explore new technologies for our stack. The final implementation of the

Discuss on Hacker News

10gen introduced MongoDB Backup Service in early May. Creating a backup service for MongoDB was a new challenge, and we used the opportunity to explore new technologies for our stack. The final implementation of the MongoDB Backup Service agent is written in Go, an open-source, natively executable language initiated and maintained by Google.

Why did we Go with Go?

The Backup Service started as a Java project, but as the project matured, the team wanted to move to a language that compiled natively on the machine. After considering a few options, the team decided that Go was the best fit for its C-like syntax, strong standard library, the resolution of concurrency problems via goroutines, and painless multi-platform distribution.

mgo

As an open-source company, 10gen is fortunate to work with MongoDB developers around the world who build open-source tools for new and emerging languages to provide users with a breadth of options to access MongoDB. One of the MongoDB Masters, Gustavo Niemeyer, has spent over two years building mgo, the MongoDB driver for Go. In that time he’s developed a great framework for accessing MongoDB through Go and Gustavo has been a valuable resource as we’ve built out the Backup Service. In his own words:

“It’s great to see not only 10gen making good use of the Go language for first-class services, but contributing to that community of developers by providing its support for the development of the Go driver in multiple ways.”

Programming the backup agent in Go and the mgo driver has been extremely satisfying. Between the lightweight syntax, the first-class concurrency and the well documented, idiomatic libraries such as mgo, Go is a great choice for writing anything from small scripts to large distributed applications.

Starting a Java project often begins with a group debate: “Maven or Ant? JUnit or TestNG? Spring or Guice?” Go has a number of conventions through which Go team has created a sensible, uniform development experience with the holy trinity of tools: go build, test and fmt.

  • The organization of source code and libraries is standardized to allow using the go build tool. See details here

  • Name test files as XXX_test.go with functions named TestXXX can be run automatically with go test

  • Braces are required on if statements and the first brace goes along with the if condition. E.g.

if x {
     doSomething()
}
Copy after login

instead of:

if x 
{
    doSomething()
}
Copy after login
  • Methods that end with an f (e.g. Printf, Fatalf) means a string formatted method will be validated in go vet that the number of substitutions (e.g. %v) matches the number of inputs to the function.

mgo is a real pleasure to use with high-quality code, thorough documentation and an API that is a thoughtful, natural blend of idiomatic Go and MongoDB.?Our team owes a lot of thanks to Gustavo for his hard work on this project.

There are other Go projects being explored at the moment and we hope to see more people using mgo in production going forward.

By the 10gen Backup Team

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Fudan NLP team released an 80-page overview of large-scale model agents, providing an overview of the current situation and future of AI agents in one article Fudan NLP team released an 80-page overview of large-scale model agents, providing an overview of the current situation and future of AI agents in one article Sep 23, 2023 am 09:01 AM

Fudan NLP team released an 80-page overview of large-scale model agents, providing an overview of the current situation and future of AI agents in one article

Tornado Cash Used in Rain Exchange Hack Tornado Cash Used in Rain Exchange Hack Aug 08, 2024 am 06:15 AM

Tornado Cash Used in Rain Exchange Hack

How to use Java Agent How to use Java Agent May 22, 2023 pm 08:52 PM

How to use Java Agent

Several design patterns that excellent agents must learn, you can learn them in one go Several design patterns that excellent agents must learn, you can learn them in one go May 30, 2024 am 09:44 AM

Several design patterns that excellent agents must learn, you can learn them in one go

Microsoft and Amazon bring Xbox Gaming to Fire TV devices Microsoft and Amazon bring Xbox Gaming to Fire TV devices Jun 28, 2024 am 08:06 AM

Microsoft and Amazon bring Xbox Gaming to Fire TV devices

Hacker Returns $19 Million of Crypto Looted From US Government Wallet, Arkham Says Hacker Returns $19 Million of Crypto Looted From US Government Wallet, Arkham Says Oct 27, 2024 am 04:12 AM

Hacker Returns $19 Million of Crypto Looted From US Government Wallet, Arkham Says

Web3 Phishing Attack Results in the Loss of $55 Million Worth of Dai Tokens Web3 Phishing Attack Results in the Loss of $55 Million Worth of Dai Tokens Aug 22, 2024 am 09:36 AM

Web3 Phishing Attack Results in the Loss of $55 Million Worth of Dai Tokens

Evan Frederick Light Pleads Guilty to Cyber Conspiracies That Stole $37 Million in Cryptocurrency Evan Frederick Light Pleads Guilty to Cyber Conspiracies That Stole $37 Million in Cryptocurrency Oct 03, 2024 am 01:08 AM

Evan Frederick Light Pleads Guilty to Cyber Conspiracies That Stole $37 Million in Cryptocurrency

See all articles