github.com/lmars/docker@v1.6.0-rc2/pkg/namesgenerator/names-generator.go (about)

     1  package namesgenerator
     2  
     3  import (
     4  	"fmt"
     5  	"math/rand"
     6  	"time"
     7  )
     8  
     9  var (
    10  	left = [...]string{
    11  		"admiring",
    12  		"adoring",
    13  		"agitated",
    14  		"angry",
    15  		"backstabbing",
    16  		"berserk",
    17  		"boring",
    18  		"clever",
    19  		"cocky",
    20  		"compassionate",
    21  		"condescending",
    22  		"cranky",
    23  		"desperate",
    24  		"determined",
    25  		"distracted",
    26  		"dreamy",
    27  		"drunk",
    28  		"ecstatic",
    29  		"elated",
    30  		"elegant",
    31  		"evil",
    32  		"fervent",
    33  		"focused",
    34  		"furious",
    35  		"gloomy",
    36  		"goofy",
    37  		"grave",
    38  		"happy",
    39  		"high",
    40  		"hopeful",
    41  		"hungry",
    42  		"insane",
    43  		"jolly",
    44  		"jovial",
    45  		"kickass",
    46  		"lonely",
    47  		"loving",
    48  		"mad",
    49  		"modest",
    50  		"naughty",
    51  		"nostalgic",
    52  		"pensive",
    53  		"prickly",
    54  		"reverent",
    55  		"romantic",
    56  		"sad",
    57  		"serene",
    58  		"sharp",
    59  		"sick",
    60  		"silly",
    61  		"sleepy",
    62  		"stoic",
    63  		"stupefied",
    64  		"suspicious",
    65  		"tender",
    66  		"thirsty",
    67  		"trusting",
    68  	}
    69  
    70  	// Docker, starting from 0.7.x, generates names from notable scientists and hackers.
    71  	right = [...]string{
    72  		// Muhammad ibn Jābir al-Ḥarrānī al-Battānī was a founding father of astronomy. https://en.wikipedia.org/wiki/Mu%E1%B8%A5ammad_ibn_J%C4%81bir_al-%E1%B8%A4arr%C4%81n%C4%AB_al-Batt%C4%81n%C4%AB
    73  		"albattani",
    74  
    75  		// June Almeida - Scottish virologist who took the first pictures of the rubella virus - https://en.wikipedia.org/wiki/June_Almeida
    76  		"almeida",
    77  
    78  		// Archimedes was a physicist, engineer and mathematician who invented too many things to list them here. https://en.wikipedia.org/wiki/Archimedes
    79  		"archimedes",
    80  
    81  		// Maria Ardinghelli - Italian translator, mathematician and physicist - https://en.wikipedia.org/wiki/Maria_Ardinghelli
    82  		"ardinghelli",
    83  
    84  		// Charles Babbage invented the concept of a programmable computer. https://en.wikipedia.org/wiki/Charles_Babbage.
    85  		"babbage",
    86  
    87  		// Stefan Banach - Polish mathematician, was one of the founders of modern functional analysis. https://en.wikipedia.org/wiki/Stefan_Banach
    88  		"banach",
    89  
    90  		// William Shockley, Walter Houser Brattain and John Bardeen co-invented the transistor (thanks Brian Goff).
    91  		// - https://en.wikipedia.org/wiki/John_Bardeen
    92  		// - https://en.wikipedia.org/wiki/Walter_Houser_Brattain
    93  		// - https://en.wikipedia.org/wiki/William_Shockley
    94  		"bardeen",
    95  		"brattain",
    96  		"shockley",
    97  
    98  		// Jean Bartik, born Betty Jean Jennings, was one of the original programmers for the ENIAC computer. https://en.wikipedia.org/wiki/Jean_Bartik
    99  		"bartik",
   100  
   101  		// Alexander Graham Bell - an eminent Scottish-born scientist, inventor, engineer and innovator who is credited with inventing the first practical telephone - https://en.wikipedia.org/wiki/Alexander_Graham_Bell
   102  		"bell",
   103  
   104  		// Elizabeth Blackwell - American doctor and first American woman to receive a medical degree - https://en.wikipedia.org/wiki/Elizabeth_Blackwell
   105  		"blackwell",
   106  
   107  		// Niels Bohr is the father of quantum theory. https://en.wikipedia.org/wiki/Niels_Bohr.
   108  		"bohr",
   109  
   110  		// Emmett Brown invented time travel. https://en.wikipedia.org/wiki/Emmett_Brown (thanks Brian Goff)
   111  		"brown",
   112  
   113  		// Rachel Carson - American marine biologist and conservationist, her book Silent Spring and other writings are credited with advancing the global environmental movement. https://en.wikipedia.org/wiki/Rachel_Carson
   114  		"carson",
   115  
   116  		// Jane Colden - American botanist widely considered the first female American botanist - https://en.wikipedia.org/wiki/Jane_Colden
   117  		"colden",
   118  
   119  		// Gerty Theresa Cori - American biochemist who became the third woman—and first American woman—to win a Nobel Prize in science, and the first woman to be awarded the Nobel Prize in Physiology or Medicine. Cori was born in Prague. https://en.wikipedia.org/wiki/Gerty_Cori
   120  		"cori",
   121  
   122  		// Marie Curie discovered radioactivity. https://en.wikipedia.org/wiki/Marie_Curie.
   123  		"curie",
   124  
   125  		// Charles Darwin established the principles of natural evolution. https://en.wikipedia.org/wiki/Charles_Darwin.
   126  		"darwin",
   127  
   128  		// Leonardo Da Vinci invented too many things to list here. https://en.wikipedia.org/wiki/Leonardo_da_Vinci.
   129  		"davinci",
   130  
   131  		// Albert Einstein invented the general theory of relativity. https://en.wikipedia.org/wiki/Albert_Einstein
   132  		"einstein",
   133  
   134  		// Gertrude Elion - American biochemist, pharmacologist and the 1988 recipient of the Nobel Prize in Medicine - https://en.wikipedia.org/wiki/Gertrude_Elion
   135  		"elion",
   136  
   137  		// Douglas Engelbart gave the mother of all demos: https://en.wikipedia.org/wiki/Douglas_Engelbart
   138  		"engelbart",
   139  
   140  		// Euclid invented geometry. https://en.wikipedia.org/wiki/Euclid
   141  		"euclid",
   142  
   143  		// Pierre de Fermat pioneered several aspects of modern mathematics. https://en.wikipedia.org/wiki/Pierre_de_Fermat
   144  		"fermat",
   145  
   146  		// Enrico Fermi invented the first nuclear reactor. https://en.wikipedia.org/wiki/Enrico_Fermi.
   147  		"fermi",
   148  
   149  		// Richard Feynman was a key contributor to quantum mechanics and particle physics. https://en.wikipedia.org/wiki/Richard_Feynman
   150  		"feynman",
   151  
   152  		// Benjamin Franklin is famous for his experiments in electricity and the invention of the lightning rod.
   153  		"franklin",
   154  
   155  		// Galileo was a founding father of modern astronomy, and faced politics and obscurantism to establish scientific truth.  https://en.wikipedia.org/wiki/Galileo_Galilei
   156  		"galileo",
   157  
   158  		// Adele Goldstine, born Adele Katz, wrote the complete technical description for the first electronic digital computer, ENIAC. https://en.wikipedia.org/wiki/Adele_Goldstine
   159  		"goldstine",
   160  
   161  		// Jane Goodall - British primatologist, ethologist, and anthropologist who is considered to be the world's foremost expert on chimpanzees - https://en.wikipedia.org/wiki/Jane_Goodall
   162  		"goodall",
   163  
   164  		// Stephen Hawking pioneered the field of cosmology by combining general relativity and quantum mechanics. https://en.wikipedia.org/wiki/Stephen_Hawking
   165  		"hawking",
   166  
   167  		// Werner Heisenberg was a founding father of quantum mechanics. https://en.wikipedia.org/wiki/Werner_Heisenberg
   168  		"heisenberg",
   169  
   170  		// Dorothy Hodgkin was a British biochemist, credited with the development of protein crystallography. She was awarded the Nobel Prize in Chemistry in 1964. https://en.wikipedia.org/wiki/Dorothy_Hodgkin
   171  		"hodgkin",
   172  
   173  		// Erna Schneider Hoover revolutionized modern communication by inventing a computerized telephon switching method. https://en.wikipedia.org/wiki/Erna_Schneider_Hoover
   174  		"hoover",
   175  
   176  		// Grace Hopper developed the first compiler for a computer programming language and  is credited with popularizing the term "debugging" for fixing computer glitches. https://en.wikipedia.org/wiki/Grace_Hopper
   177  		"hopper",
   178  
   179  		// Hypatia - Greek Alexandrine Neoplatonist philosopher in Egypt who was one of the earliest mothers of mathematics - https://en.wikipedia.org/wiki/Hypatia
   180  		"hypatia",
   181  
   182  		// Yeong-Sil Jang was a Korean scientist and astronomer during the Joseon Dynasty; he invented the first metal printing press and water gauge. https://en.wikipedia.org/wiki/Jang_Yeong-sil
   183  		"jang",
   184  
   185  		// Karen Spärck Jones came up with the concept of inverse document frequency, which is used in most search engines today. https://en.wikipedia.org/wiki/Karen_Sp%C3%A4rck_Jones
   186  		"jones",
   187  
   188  		// Maria Kirch - German astronomer and first woman to discover a comet - https://en.wikipedia.org/wiki/Maria_Margarethe_Kirch
   189  		"kirch",
   190  
   191  		// Sophie Kowalevski - Russian mathematician responsible for important original contributions to analysis, differential equations and mechanics - https://en.wikipedia.org/wiki/Sofia_Kovalevskaya
   192  		"kowalevski",
   193  
   194  		// Marie-Jeanne de Lalande - French astronomer, mathematician and cataloguer of stars - https://en.wikipedia.org/wiki/Marie-Jeanne_de_Lalande
   195  		"lalande",
   196  
   197  		// Mary Leakey - British paleoanthropologist who discovered the first fossilized Proconsul skull - https://en.wikipedia.org/wiki/Mary_Leakey
   198  		"leakey",
   199  
   200  		// Ada Lovelace invented the first algorithm. https://en.wikipedia.org/wiki/Ada_Lovelace (thanks James Turnbull)
   201  		"lovelace",
   202  
   203  		// Auguste and Louis Lumière - the first filmmakers in history - https://en.wikipedia.org/wiki/Auguste_and_Louis_Lumi%C3%A8re
   204  		"lumiere",
   205  
   206  		// Maria Mayer - American theoretical physicist and Nobel laureate in Physics for proposing the nuclear shell model of the atomic nucleus - https://en.wikipedia.org/wiki/Maria_Mayer
   207  		"mayer",
   208  
   209  		// John McCarthy invented LISP: https://en.wikipedia.org/wiki/John_McCarthy_(computer_scientist)
   210  		"mccarthy",
   211  
   212  		// Barbara McClintock - a distinguished American cytogeneticist, 1983 Nobel Laureate in Physiology or Medicine for discovering transposons. https://en.wikipedia.org/wiki/Barbara_McClintock
   213  		"mcclintock",
   214  
   215  		// Malcolm McLean invented the modern shipping container: https://en.wikipedia.org/wiki/Malcom_McLean
   216  		"mclean",
   217  
   218  		// Lise Meitner - Austrian/Swedish physicist who was involved in the discovery of nuclear fission. The element meitnerium is named after her - https://en.wikipedia.org/wiki/Lise_Meitner
   219  		"meitner",
   220  
   221  		// Johanna Mestorf - German prehistoric archaeologist and first female museum director in Germany - https://en.wikipedia.org/wiki/Johanna_Mestorf
   222  		"mestorf",
   223  
   224  		// Samuel Morse - contributed to the invention of a single-wire telegraph system based on European telegraphs and was a co-developer of the Morse code - https://en.wikipedia.org/wiki/Samuel_Morse
   225  		"morse",
   226  
   227  		// Isaac Newton invented classic mechanics and modern optics. https://en.wikipedia.org/wiki/Isaac_Newton
   228  		"newton",
   229  
   230  		// Alfred Nobel - a Swedish chemist, engineer, innovator, and armaments manufacturer (inventor of dynamite) - https://en.wikipedia.org/wiki/Alfred_Nobel
   231  		"nobel",
   232  
   233  		// Cecilia Payne-Gaposchkin was an astronomer and astrophysicist who, in 1925, proposed in her Ph.D. thesis an explanation for the composition of stars in terms of the relative abundances of hydrogen and helium. https://en.wikipedia.org/wiki/Cecilia_Payne-Gaposchkin
   234  		"payne",
   235  
   236  		// Ambroise Pare invented modern surgery. https://en.wikipedia.org/wiki/Ambroise_Par%C3%A9
   237  		"pare",
   238  
   239  		// Louis Pasteur discovered vaccination, fermentation and pasteurization. https://en.wikipedia.org/wiki/Louis_Pasteur.
   240  		"pasteur",
   241  
   242  		// Radia Perlman is a software designer and network engineer and most famous for her invention of the spanning-tree protocol (STP). https://en.wikipedia.org/wiki/Radia_Perlman
   243  		"perlman",
   244  
   245  		// Rob Pike was a key contributor to Unix, Plan 9, the X graphic system, utf-8, and the Go programming language. https://en.wikipedia.org/wiki/Rob_Pike
   246  		"pike",
   247  
   248  		// Henri Poincaré made fundamental contributions in several fields of mathematics. https://en.wikipedia.org/wiki/Henri_Poincar%C3%A9
   249  		"poincare",
   250  
   251  		// Laura Poitras is a director and producer whose work, made possible by open source crypto tools, advances the causes of truth and freedom of information by reporting disclosures by whistleblowers such as Edward Snowden. https://en.wikipedia.org/wiki/Laura_Poitras
   252  		"poitras",
   253  
   254  		// Claudius Ptolemy - a Greco-Egyptian writer of Alexandria, known as a mathematician, astronomer, geographer, astrologer, and poet of a single epigram in the Greek Anthology - https://en.wikipedia.org/wiki/Ptolemy
   255  		"ptolemy",
   256  
   257  		// Dennis Ritchie and Ken Thompson created UNIX and the C programming language.
   258  		// - https://en.wikipedia.org/wiki/Dennis_Ritchie
   259  		// - https://en.wikipedia.org/wiki/Ken_Thompson
   260  		"ritchie",
   261  		"thompson",
   262  
   263  		// Rosalind Franklin - British biophysicist and X-ray crystallographer whose research was critical to the understanding of DNA - https://en.wikipedia.org/wiki/Rosalind_Franklin
   264  		"rosalind",
   265  
   266  		// Jean E. Sammet developed FORMAC, the first widely used computer language for symbolic manipulation of mathematical formulas. https://en.wikipedia.org/wiki/Jean_E._Sammet
   267  		"sammet",
   268  
   269  		// Françoise Barré-Sinoussi - French virologist and Nobel Prize Laureate in Physiology or Medicine; her work was fundamental in identifying HIV as the cause of AIDS. https://en.wikipedia.org/wiki/Fran%C3%A7oise_Barr%C3%A9-Sinoussi
   270  		"sinoussi",
   271  
   272  		// Richard Matthew Stallman - the founder of the Free Software movement, the GNU project, the Free Software Foundation, and the League for Programming Freedom. He also invented the concept of copyleft to protect the ideals of this movement, and enshrined this concept in the widely-used GPL (General Public License) for software. https://en.wikiquote.org/wiki/Richard_Stallman
   273  		"stallman",
   274  
   275  		// Aaron Swartz was influential in creating RSS, Markdown, Creative Commons, Reddit, and much of the internet as we know it today. He was devoted to freedom of information on the web. https://en.wikiquote.org/wiki/Aaron_Swartz
   276  		"swartz",
   277  
   278  		// Nikola Tesla invented the AC electric system and every gadget ever used by a James Bond villain. https://en.wikipedia.org/wiki/Nikola_Tesla
   279  		"tesla",
   280  
   281  		// Linus Torvalds invented Linux and Git. https://en.wikipedia.org/wiki/Linus_Torvalds
   282  		"torvalds",
   283  
   284  		// Alan Turing was a founding father of computer science. https://en.wikipedia.org/wiki/Alan_Turing.
   285  		"turing",
   286  
   287  		// Sophie Wilson designed the first Acorn Micro-Computer and the instruction set for ARM processors. https://en.wikipedia.org/wiki/Sophie_Wilson
   288  		"wilson",
   289  
   290  		// Steve Wozniak invented the Apple I and Apple II. https://en.wikipedia.org/wiki/Steve_Wozniak
   291  		"wozniak",
   292  
   293  		// The Wright brothers, Orville and Wilbur - credited with inventing and building the world's first successful airplane and making the first controlled, powered and sustained heavier-than-air human flight - https://en.wikipedia.org/wiki/Wright_brothers
   294  		"wright",
   295  
   296  		// Rosalyn Sussman Yalow - Rosalyn Sussman Yalow was an American medical physicist, and a co-winner of the 1977 Nobel Prize in Physiology or Medicine for development of the radioimmunoassay technique. https://en.wikipedia.org/wiki/Rosalyn_Sussman_Yalow
   297  		"yalow",
   298  
   299  		// Ada Yonath - an Israeli crystallographer, the first woman from the Middle East to win a Nobel prize in the sciences. https://en.wikipedia.org/wiki/Ada_Yonath
   300  		"yonath",
   301  	}
   302  )
   303  
   304  func GetRandomName(retry int) string {
   305  	rand.Seed(time.Now().UnixNano())
   306  
   307  begin:
   308  	name := fmt.Sprintf("%s_%s", left[rand.Intn(len(left))], right[rand.Intn(len(right))])
   309  	if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
   310  		goto begin
   311  	}
   312  
   313  	if retry > 0 {
   314  		name = fmt.Sprintf("%s%d", name, rand.Intn(10))
   315  	}
   316  	return name
   317  }