I left my leg in Jaglan Beta

I’d far rather be happy than right any day.

Docker Code Curiosities

Code is the best documentation place at the end, and despites the fact that reading it is time consuming and hard to understand, sometimes it could make you happier.

This post is about the unrelated things I found (for now) in docker code.

The meaning of life

Given the name of the blog, this one is not unnoticed to my eyes.

meaning_of_lifelink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
func TestOutputAddEnv(t *testing.T) {
  input := "{\"foo\": \"bar\", \"answer_to_life_the_universe_and_everything\": 42}"
  o := NewOutput()
  result, err := o.AddEnv()
  if err != nil {
      t.Fatal(err)
  }
  o.Write([]byte(input))
  o.Close()
  if v := result.Get("foo"); v != "bar" {
      t.Errorf("Expected %v, got %v", "bar", v)
  }
  if v := result.GetInt("answer_to_life_the_universe_and_everything"); v != 42 {
      t.Errorf("Expected %v, got %v", 42, v)
  }
  if v := result.Get("this-value-doesnt-exist"); v != "" {
      t.Errorf("Expected %v, got %v", "", v)
  }
}

Remember, don’t forget your towel!

Names generator

I enjoyed this wink, I mean, the whole file. It is worth to read it all, since all the names are quoted and this quick reference could wake up some interest about someone.

things_clearlink
1
2
3
4
5
begin:
  name := fmt.Sprintf("%s_%s", left[rand.Intn(len(left))], right[rand.Intn(len(right))])
  if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
      goto begin
  }

I have to say I agree.

At least they are not as hard as the ones in linux code.

Comments