github.com/torfuzx/docker@v1.8.1/pkg/namesgenerator/names-generator.go (about)

     1  package namesgenerator
     2  
     3  import (
     4  	"fmt"
     5  	"math/rand"
     6  
     7  	"github.com/docker/docker/pkg/random"
     8  )
     9  
    10  var (
    11  	left = [...]string{
    12  		"admiring",
    13  		"adoring",
    14  		"agitated",
    15  		"angry",
    16  		"backstabbing",
    17  		"berserk",
    18  		"boring",
    19  		"clever",
    20  		"cocky",
    21  		"compassionate",
    22  		"condescending",
    23  		"cranky",
    24  		"desperate",
    25  		"determined",
    26  		"distracted",
    27  		"dreamy",
    28  		"drunk",
    29  		"ecstatic",
    30  		"elated",
    31  		"elegant",
    32  		"evil",
    33  		"fervent",
    34  		"focused",
    35  		"furious",
    36  		"gloomy",
    37  		"goofy",
    38  		"grave",
    39  		"happy",
    40  		"high",
    41  		"hopeful",
    42  		"hungry",
    43  		"insane",
    44  		"jolly",
    45  		"jovial",
    46  		"kickass",
    47  		"lonely",
    48  		"loving",
    49  		"mad",
    50  		"modest",
    51  		"naughty",
    52  		"nostalgic",
    53  		"pensive",
    54  		"prickly",
    55  		"reverent",
    56  		"romantic",
    57  		"sad",
    58  		"serene",
    59  		"sharp",
    60  		"sick",
    61  		"silly",
    62  		"sleepy",
    63  		"stoic",
    64  		"stupefied",
    65  		"suspicious",
    66  		"tender",
    67  		"thirsty",
    68  		"trusting",
    69  	}
    70  
    71  	// Docker, starting from 0.7.x, generates names from notable scientists and hackers.
    72  	right = [...]string{
    73  		// 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
    74  		"albattani",
    75  
    76  		// June Almeida - Scottish virologist who took the first pictures of the rubella virus - https://en.wikipedia.org/wiki/June_Almeida
    77  		"almeida",
    78  
    79  		// Archimedes was a physicist, engineer and mathematician who invented too many things to list them here. https://en.wikipedia.org/wiki/Archimedes
    80  		"archimedes",
    81  
    82  		// Maria Ardinghelli - Italian translator, mathematician and physicist - https://en.wikipedia.org/wiki/Maria_Ardinghelli
    83  		"ardinghelli",
    84  
    85  		// Aryabhata - Ancient Indian mathematician-astronomer during 476-550 CE https://en.wikipedia.org/wiki/Aryabhata
    86  		"aryabhata",
    87  
    88  		// Charles Babbage invented the concept of a programmable computer. https://en.wikipedia.org/wiki/Charles_Babbage.
    89  		"babbage",
    90  
    91  		// Stefan Banach - Polish mathematician, was one of the founders of modern functional analysis. https://en.wikipedia.org/wiki/Stefan_Banach
    92  		"banach",
    93  
    94  		// William Shockley, Walter Houser Brattain and John Bardeen co-invented the transistor (thanks Brian Goff).
    95  		// - https://en.wikipedia.org/wiki/John_Bardeen
    96  		// - https://en.wikipedia.org/wiki/Walter_Houser_Brattain
    97  		// - https://en.wikipedia.org/wiki/William_Shockley
    98  		"bardeen",
    99  		"brattain",
   100  		"shockley",
   101  
   102  		// Jean Bartik, born Betty Jean Jennings, was one of the original programmers for the ENIAC computer. https://en.wikipedia.org/wiki/Jean_Bartik
   103  		"bartik",
   104  
   105  		// 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
   106  		"bell",
   107  
   108  		// Homi J Bhabha - was an Indian nuclear physicist, founding director, and professor of physics at the Tata Institute of Fundamental Research. Colloquially known as "father of Indian nuclear programme"- https://en.wikipedia.org/wiki/Homi_J._Bhabha
   109  		"bhabha",
   110  
   111  		// Bhaskara II - Ancient Indian mathematician-astronomer whose work on calculus predates Newton and Leibniz by over half a millenium - https://en.wikipedia.org/wiki/Bh%C4%81skara_II#Calculus
   112  		"bhaskara",
   113  
   114  		// Elizabeth Blackwell - American doctor and first American woman to receive a medical degree - https://en.wikipedia.org/wiki/Elizabeth_Blackwell
   115  		"blackwell",
   116  
   117  		// Niels Bohr is the father of quantum theory. https://en.wikipedia.org/wiki/Niels_Bohr.
   118  		"bohr",
   119  
   120  		// Satyendra Nath Bose - He provided the foundation for Bose–Einstein statistics and the theory of the Bose–Einstein condensate. - https://en.wikipedia.org/wiki/Satyendra_Nath_Bose
   121  		"bose",
   122  
   123  		// Brahmagupta - Ancient Indian mathematician during 598-670 CE who gave rules to compute with zero - https://en.wikipedia.org/wiki/Brahmagupta#Zero
   124  		"brahmagupta",
   125  
   126  		// Emmett Brown invented time travel. https://en.wikipedia.org/wiki/Emmett_Brown (thanks Brian Goff)
   127  		"brown",
   128  
   129  		// 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
   130  		"carson",
   131  
   132  		//Subrahmanyan Chandrasekhar - Astrophysicist known for his mathematical theory on different stages and evolution in structures of the stars. He has won nobel prize for physics - https://en.wikipedia.org/wiki/Subrahmanyan_Chandrasekhar
   133  		"chandrasekhar",
   134  
   135  		// Jane Colden - American botanist widely considered the first female American botanist - https://en.wikipedia.org/wiki/Jane_Colden
   136  		"colden",
   137  
   138  		// 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
   139  		"cori",
   140  
   141  		// Seymour Roger Cray was an American electrical engineer and supercomputer architect who designed a series of computers that were the fastest in the world for decades. https://en.wikipedia.org/wiki/Seymour_Cray
   142  		"cray",
   143  
   144  		// Marie Curie discovered radioactivity. https://en.wikipedia.org/wiki/Marie_Curie.
   145  		"curie",
   146  
   147  		// Charles Darwin established the principles of natural evolution. https://en.wikipedia.org/wiki/Charles_Darwin.
   148  		"darwin",
   149  
   150  		// Leonardo Da Vinci invented too many things to list here. https://en.wikipedia.org/wiki/Leonardo_da_Vinci.
   151  		"davinci",
   152  
   153  		// Albert Einstein invented the general theory of relativity. https://en.wikipedia.org/wiki/Albert_Einstein
   154  		"einstein",
   155  
   156  		// Gertrude Elion - American biochemist, pharmacologist and the 1988 recipient of the Nobel Prize in Medicine - https://en.wikipedia.org/wiki/Gertrude_Elion
   157  		"elion",
   158  
   159  		// Douglas Engelbart gave the mother of all demos: https://en.wikipedia.org/wiki/Douglas_Engelbart
   160  		"engelbart",
   161  
   162  		// Euclid invented geometry. https://en.wikipedia.org/wiki/Euclid
   163  		"euclid",
   164  
   165  		// Pierre de Fermat pioneered several aspects of modern mathematics. https://en.wikipedia.org/wiki/Pierre_de_Fermat
   166  		"fermat",
   167  
   168  		// Enrico Fermi invented the first nuclear reactor. https://en.wikipedia.org/wiki/Enrico_Fermi.
   169  		"fermi",
   170  
   171  		// Richard Feynman was a key contributor to quantum mechanics and particle physics. https://en.wikipedia.org/wiki/Richard_Feynman
   172  		"feynman",
   173  
   174  		// Benjamin Franklin is famous for his experiments in electricity and the invention of the lightning rod.
   175  		"franklin",
   176  
   177  		// Galileo was a founding father of modern astronomy, and faced politics and obscurantism to establish scientific truth.  https://en.wikipedia.org/wiki/Galileo_Galilei
   178  		"galileo",
   179  
   180  		// Adele Goldstine, born Adele Katz, wrote the complete technical description for the first electronic digital computer, ENIAC. https://en.wikipedia.org/wiki/Adele_Goldstine
   181  		"goldstine",
   182  
   183  		// 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
   184  		"goodall",
   185  
   186  		// Stephen Hawking pioneered the field of cosmology by combining general relativity and quantum mechanics. https://en.wikipedia.org/wiki/Stephen_Hawking
   187  		"hawking",
   188  
   189  		// Werner Heisenberg was a founding father of quantum mechanics. https://en.wikipedia.org/wiki/Werner_Heisenberg
   190  		"heisenberg",
   191  
   192  		// 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
   193  		"hodgkin",
   194  
   195  		// Erna Schneider Hoover revolutionized modern communication by inventing a computerized telephon switching method. https://en.wikipedia.org/wiki/Erna_Schneider_Hoover
   196  		"hoover",
   197  
   198  		// 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
   199  		"hopper",
   200  
   201  		// Hypatia - Greek Alexandrine Neoplatonist philosopher in Egypt who was one of the earliest mothers of mathematics - https://en.wikipedia.org/wiki/Hypatia
   202  		"hypatia",
   203  
   204  		// 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
   205  		"jang",
   206  
   207  		// 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
   208  		"jones",
   209  
   210  		// Jack Kilby and Robert Noyce have invented silicone integrated circuits and gave Silicon Valley its name.
   211  		// - https://en.wikipedia.org/wiki/Jack_Kilby
   212  		// - https://en.wikipedia.org/wiki/Robert_Noyce
   213  		"kilby",
   214  		"noyce",
   215  
   216  		// A. P. J. Abdul Kalam - is an Indian scientist aka Missile Man of India for his work on the development of ballistic missile and launch vehicle technology - https://en.wikipedia.org/wiki/A._P._J._Abdul_Kalam
   217  		"kalam",
   218  
   219  		// Har Gobind Khorana - Indian-American biochemist who shared the 1968 Nobel Prize for Physiology - https://en.wikipedia.org/wiki/Har_Gobind_Khorana
   220  		"khorana",
   221  
   222  		// Maria Kirch - German astronomer and first woman to discover a comet - https://en.wikipedia.org/wiki/Maria_Margarethe_Kirch
   223  		"kirch",
   224  
   225  		// Sophie Kowalevski - Russian mathematician responsible for important original contributions to analysis, differential equations and mechanics - https://en.wikipedia.org/wiki/Sofia_Kovalevskaya
   226  		"kowalevski",
   227  
   228  		// Marie-Jeanne de Lalande - French astronomer, mathematician and cataloguer of stars - https://en.wikipedia.org/wiki/Marie-Jeanne_de_Lalande
   229  		"lalande",
   230  
   231  		// Mary Leakey - British paleoanthropologist who discovered the first fossilized Proconsul skull - https://en.wikipedia.org/wiki/Mary_Leakey
   232  		"leakey",
   233  
   234  		// Ada Lovelace invented the first algorithm. https://en.wikipedia.org/wiki/Ada_Lovelace (thanks James Turnbull)
   235  		"lovelace",
   236  
   237  		// Auguste and Louis Lumière - the first filmmakers in history - https://en.wikipedia.org/wiki/Auguste_and_Louis_Lumi%C3%A8re
   238  		"lumiere",
   239  
   240  		// Mahavira - Ancient Indian mathematician during 9th century AD who discovered basic algebraic identities - https://en.wikipedia.org/wiki/Mah%C4%81v%C4%ABra_(mathematician)
   241  		"mahavira",
   242  
   243  		// 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
   244  		"mayer",
   245  
   246  		// John McCarthy invented LISP: https://en.wikipedia.org/wiki/John_McCarthy_(computer_scientist)
   247  		"mccarthy",
   248  
   249  		// Barbara McClintock - a distinguished American cytogeneticist, 1983 Nobel Laureate in Physiology or Medicine for discovering transposons. https://en.wikipedia.org/wiki/Barbara_McClintock
   250  		"mcclintock",
   251  
   252  		// Malcolm McLean invented the modern shipping container: https://en.wikipedia.org/wiki/Malcom_McLean
   253  		"mclean",
   254  
   255  		// 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
   256  		"meitner",
   257  
   258  		// Johanna Mestorf - German prehistoric archaeologist and first female museum director in Germany - https://en.wikipedia.org/wiki/Johanna_Mestorf
   259  		"mestorf",
   260  
   261  		// 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
   262  		"morse",
   263  
   264  		// Isaac Newton invented classic mechanics and modern optics. https://en.wikipedia.org/wiki/Isaac_Newton
   265  		"newton",
   266  
   267  		// Alfred Nobel - a Swedish chemist, engineer, innovator, and armaments manufacturer (inventor of dynamite) - https://en.wikipedia.org/wiki/Alfred_Nobel
   268  		"nobel",
   269  
   270  		// Panini - Ancient Indian linguist and grammarian from 4th century CE who worked on the world's first formal system - https://en.wikipedia.org/wiki/P%C4%81%E1%B9%87ini#Comparison_with_modern_formal_systems
   271  		"panini",
   272  
   273  		// 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
   274  		"payne",
   275  
   276  		// Ambroise Pare invented modern surgery. https://en.wikipedia.org/wiki/Ambroise_Par%C3%A9
   277  		"pare",
   278  
   279  		// Louis Pasteur discovered vaccination, fermentation and pasteurization. https://en.wikipedia.org/wiki/Louis_Pasteur.
   280  		"pasteur",
   281  
   282  		// 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
   283  		"perlman",
   284  
   285  		// 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
   286  		"pike",
   287  
   288  		// Henri Poincaré made fundamental contributions in several fields of mathematics. https://en.wikipedia.org/wiki/Henri_Poincar%C3%A9
   289  		"poincare",
   290  
   291  		// 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
   292  		"poitras",
   293  
   294  		// 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
   295  		"ptolemy",
   296  
   297  		// C. V. Raman - Indian physicist who won the Nobel Prize in 1930 for proposing the Raman effect. - https://en.wikipedia.org/wiki/C._V._Raman
   298  		"raman",
   299  
   300  		// Srinivasa Ramanujan - Indian mathematician and autodidact who made extraordinary contributions to mathematical analysis, number theory, infinite series, and continued fractions. - https://en.wikipedia.org/wiki/Srinivasa_Ramanujan
   301  		"ramanujan",
   302  
   303  		// Dennis Ritchie and Ken Thompson created UNIX and the C programming language.
   304  		// - https://en.wikipedia.org/wiki/Dennis_Ritchie
   305  		// - https://en.wikipedia.org/wiki/Ken_Thompson
   306  		"ritchie",
   307  		"thompson",
   308  
   309  		// Rosalind Franklin - British biophysicist and X-ray crystallographer whose research was critical to the understanding of DNA - https://en.wikipedia.org/wiki/Rosalind_Franklin
   310  		"rosalind",
   311  
   312  		// Meghnad Saha - Indian astrophysicist best known for his development of the Saha equation, used to describe chemical and physical conditions in stars - https://en.wikipedia.org/wiki/Meghnad_Saha
   313  		"saha",
   314  
   315  		// 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
   316  		"sammet",
   317  
   318  		// 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
   319  		"sinoussi",
   320  
   321  		// 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
   322  		"stallman",
   323  
   324  		// 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
   325  		"swartz",
   326  
   327  		// Nikola Tesla invented the AC electric system and every gadget ever used by a James Bond villain. https://en.wikipedia.org/wiki/Nikola_Tesla
   328  		"tesla",
   329  
   330  		// Linus Torvalds invented Linux and Git. https://en.wikipedia.org/wiki/Linus_Torvalds
   331  		"torvalds",
   332  
   333  		// Alan Turing was a founding father of computer science. https://en.wikipedia.org/wiki/Alan_Turing.
   334  		"turing",
   335  
   336  		// Varahamihira - Ancient Indian mathematician who discovered trigonometric formulae during 505-587 CE - https://en.wikipedia.org/wiki/Var%C4%81hamihira#Contributions
   337  		"varahamihira",
   338  
   339  		// Sir Mokshagundam Visvesvaraya - is a notable Indian engineer.  He is a recipient of the Indian Republic's highest honour, the Bharat Ratna, in 1955. On his birthday, 15 September is celebrated as Engineer's Day in India in his memory - https://en.wikipedia.org/wiki/Visvesvaraya
   340  		"visvesvaraya",
   341  
   342  		// Sophie Wilson designed the first Acorn Micro-Computer and the instruction set for ARM processors. https://en.wikipedia.org/wiki/Sophie_Wilson
   343  		"wilson",
   344  
   345  		// Steve Wozniak invented the Apple I and Apple II. https://en.wikipedia.org/wiki/Steve_Wozniak
   346  		"wozniak",
   347  
   348  		// 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
   349  		"wright",
   350  
   351  		// 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
   352  		"yalow",
   353  
   354  		// 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
   355  		"yonath",
   356  	}
   357  
   358  	rnd = rand.New(random.NewSource())
   359  )
   360  
   361  // GetRandomName generates a random name from the list of adjectives and surnames in this package
   362  // formatted as "adjective_surname". For example 'focused_turing'. If retry is non-zero, a random
   363  // integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`
   364  func GetRandomName(retry int) string {
   365  begin:
   366  	name := fmt.Sprintf("%s_%s", left[rnd.Intn(len(left))], right[rnd.Intn(len(right))])
   367  	if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
   368  		goto begin
   369  	}
   370  
   371  	if retry > 0 {
   372  		name = fmt.Sprintf("%s%d", name, rnd.Intn(10))
   373  	}
   374  	return name
   375  }