(1) ある日、yamaya さんという怖い方がこのツイートを投稿する。
We Gophers, love table-driven-tests, it makes our unittesting structured, and makes it easy to add different test cases with ease.
Let’s create our table driven test, for convenience, I chose to use t.Log
as the test function.
Notice that we don't have any assertion in this test, it is not needed to for the demonstration.
func TestTLog(t *testing.T) {
t.Parallel()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl | |
# | |
# Written in 2017 by Kazuho Oku | |
# | |
# To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. | |
# You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | |
# | |
use strict; | |
use warnings; |
あなたのコードに gofmt
を走らせると、自動的に機械的に直すことのできるスタイルの大部分を修正してくれます。
世にあるGolang コードのほとんどすべてが gofmt
を使っています。
この文章の残りは機械的に直すことのできないポイントについて解説します。
代わりに goimports
を使う手段もあります。
- Raftという分散合意アルゴリズムの紹介
- 論文: In Search of an Understandable Consensus ALgorithm (Extended Version)
- Raft三日目くらいの人が自分の理解をもとに(適当に)書いています
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lean and Mean Serial DSL for CoffeeScript | |
# (based of https://gist.github.com/1090670 by timcameronryan) | |
serial = (spec) -> | |
commands = (func for key, func of spec when key != 'catch') | |
next = (err, args...) -> | |
return spec.catch(err) if err | |
commands.shift().apply(next, args) if commands.length > 0 | |
next null | |
return |