1. Go / Говнокод #26743

    0

    1. 1
    https://m.vk.com/wall-30666517_1672469

    Из исходников и документации Go убрали фразы whitelist/blacklist и master/slave.
    Всё из-за протестов, которые сейчас проходят в Америке.

    Фразы «blacklist» и «whitelist» заменили на «blocklist» и «allowlist», а «master» и «slave»
    в зависимости от контекста на «process», «pty», «proc» и «control».

    Отмечается, что изменения не приведут к нарушению обратной совместимости и путанице, так как
    большая часть исправлений приходится на комментарии, тесты и внутренние переменные.

    OlegUP, 08 Июня 2020

    Комментарии (77)
  2. Go / Говнокод #26717

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    func GetUser() *User {
        defer func() {
            time.Sleep(100 * time.Millisecond)
        }()
        return &User{}
    }

    Паттерн: поработал - отдохни.

    Pattern: worked hard - have a rest

    anon007, 01 Июня 2020

    Комментарии (6)
  3. Go / Говнокод #26716

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    func (svc *UserSvc) isEmptyName(name model.User_Name) bool {
      if name.First.RU == "" {
        if name.First.EN == "" {
          if name.First.TR == "" {
            if name.First.IT == "" {
              if name.Last.RU == "" {
                if name.Last.EN == "" {
                  if name.Last.TR == "" {
                    if name.Last.IT == "" {
                      return true
                    }
                  }
                }
              }
            }
          }
        }
      }
      return false
    }

    Проверка заполненности имени пользователя хотя - бы на одном из языков.

    anon007, 01 Июня 2020

    Комментарии (54)
  4. Go / Говнокод #26599

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    Currently, we're ignoring failures to mlock signal stacks in the
    workaround for #35777. This means if your mlock limit is low, you'll
    instead get random memory corruption, which seems like the wrong
    trade-off.

    самый лучший язык на свете продолжает шпарить, отказались от free after use - получили «забыл сделать if (err != nil)»

    https://github.com/golang/go/commit/69614c0d0e05787c8203bdc364c3293e1cf5094a

    Fike, 24 Апреля 2020

    Комментарии (26)
  5. Go / Говнокод #26520

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    // sumEqual reports whether u + v == w exactly.
    func sumEqual(u, v, w float64) bool {
    	return (u+v == w) && (u == w-v) && (v == w-u)
    }

    https://github.com/golang/geo/blob/a8523298cefedcf7b70bbbf4eeef24cbb3258376/s2/edge_clipping.go#L182

    походу питух-затейник опять сбежал

    Fike, 21 Марта 2020

    Комментарии (61)
  6. Go / Говнокод #26349

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    // GostServer is the type that contains all of the relevant information to set
    // up the GOST HTTP Server
    type GostServer struct {
    	host       string      // Hostname for example "localhost" or "192.168.1.14"
    	port       int         // Port number where you want to run your http server on
    	api        *models.API // SensorThings api to interact with from the HttpServer
    	https      bool
    	httpsCert  string
    	httpsKey   string
    	httpServer *http.Server
    }
    
    // CreateServer initialises a new GOST HTTPServer based on the given parameters
    func CreateServer(host string, port int, api *models.API, https bool, httpsCert, httpsKey string) Server {
    	setupLogger()
    	a := *api
    	router := CreateRouter(api)
    	return &GostServer{
    		host:      host,
    		port:      port,
    		api:       api,
    		https:     https,
    		httpsCert: httpsCert,
    		httpsKey:  httpsKey,
    		httpServer: &http.Server{
    			Addr:         fmt.Sprintf("%s:%s", host, strconv.Itoa(port)),
    			Handler:      PostProcessHandler(RequestErrorHandler(LowerCaseURI(router)), a.GetConfig().Server.ExternalURI),
    			ReadTimeout:  30 * time.Second,
    			WriteTimeout: 30 * time.Second,
    		},
    	}
    }
    
    // Start command to start the GOST HTTPServer
    func (s *GostServer) Start() {
    	t := "HTTP"
    	if s.https {
    		t = "HTTPS"
    	}
    
    	logger.Infof("Started GOST %v Server on %v:%v", t, s.host, s.port)
    
    	var err error
    	if s.https {
    		err = s.httpServer.ListenAndServeTLS(s.httpsCert, s.httpsKey)
    	} else {
    		err = s.httpServer.ListenAndServe()
    	}
    
    	if err != nil {
    		logger.Panicf("GOST server not properly stopped: %v", err)
    	}
    }
    
    // Stop command to stop the GOST HTTP server
    func (s *GostServer) Stop() {
    	if s.httpServer != nil {
    		logger.Info("Stopping HTTP(S) Server")
    		s.httpServer.Shutdown(context.Background())
    	}
    }

    Нашёл ГостСервер го

    https://github.com/gost/server/blob/master/http/gostserver.go

    gostinho, 13 Января 2020

    Комментарии (23)
  7. Go / Говнокод #25839

    −2

    1. 1
    TOCTOU race condition in Docker allows root access to the filesystem of the host platform.[4]

    6a6yuH, 15 Сентября 2019

    Комментарии (65)
  8. Go / Говнокод #25729

    −2

    1. 1
    Ьут оказывается go есть

    TOPT, 22 Июля 2019

    Комментарии (29)