10 examples of 'go init' in Go

Every line of 'go init' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
945func (ly *Layer) InitGInc() {
946 for ni := range ly.Neurons {
947 nrn := &ly.Neurons[ni]
948 if nrn.IsOff() {
949 continue
950 }
951 ly.Act.InitGInc(nrn)
952 }
953 for _, p := range ly.RcvPrjns {
954 if p.IsOff() {
955 continue
956 }
957 p.(LeabraPrjn).InitGInc()
958 }
959}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

503func (ly *Layer) InitGInc() {
504 for ni := range ly.Neurons {
505 nrn := &ly.Neurons[ni]
506 nrn.GeInc = 0
507 nrn.GiInc = 0
508 }
509 for _, p := range ly.RecvPrjns {
510 if p.IsOff() {
511 continue
512 }
513 p.(LeabraPrjn).InitGInc()
514 }
515}
51func init() {
52 lib = syscall.NewLazyDLL(GetCurrPath() + "/../lib/easyprexport.dll")
53 err := lib.Load()
54 if err != nil {
55 fmt.Println(err)
56 os.Exit(1)
57 }
58 inito = lib.NewProc("init")
59 plateRecognize = lib.NewProc("plateRecognize")
60 deleteptr = lib.NewProc("deleteptr")
61}
17func init() {
18 c := make(chan int, 1)
19 defer func() {
20 c <- 0
21 }()
22 go func() {
23 os.Exit(<-c)
24 }()
25 runtime.Goexit()
26}
979func init() {
980 methods := []*py.Method{
981 py.MustNewMethod("time", time_time, 0, time_doc),
982 py.MustNewMethod("clock", time_clock, 0, clock_doc),
983 py.MustNewMethod("clock_gettime", time_clock_gettime, 0, clock_gettime_doc),
984 py.MustNewMethod("clock_settime", time_clock_settime, 0, clock_settime_doc),
985 py.MustNewMethod("clock_getres", time_clock_getres, 0, clock_getres_doc),
986 py.MustNewMethod("sleep", time_sleep, 0, sleep_doc),
987 py.MustNewMethod("gmtime", time_gmtime, 0, gmtime_doc),
988 py.MustNewMethod("localtime", time_localtime, 0, localtime_doc),
989 py.MustNewMethod("asctime", time_asctime, 0, asctime_doc),
990 py.MustNewMethod("ctime", time_ctime, 0, ctime_doc),
991 py.MustNewMethod("mktime", time_mktime, 0, mktime_doc),
992 py.MustNewMethod("strftime", time_strftime, 0, strftime_doc),
993 py.MustNewMethod("strptime", time_strptime, 0, strptime_doc),
994 py.MustNewMethod("tzset", time_tzset, 0, tzset_doc),
995 py.MustNewMethod("monotonic", time_monotonic, 0, monotonic_doc),
996 py.MustNewMethod("process_time", time_process_time, 0, process_time_doc),
997 py.MustNewMethod("perf_counter", time_perf_counter, 0, perf_counter_doc),
998 py.MustNewMethod("get_clock_info", time_get_clock_info, 0, get_clock_info_doc),
999 }
1000 globals := py.StringDict{
1001 //"version": py.Int(MARSHAL_VERSION),
1002 }
1003 py.NewModule("time", module_doc, methods, globals)
1004
1005}
9func init() {
10 maxCPU := runtime.NumCPU()
11 runtime.GOMAXPROCS(runtime.NumCPU())
12 log.Println("Concurrent execution with", maxCPU, "CPUs.")
13}
15func Init(arch *gc.Arch) {
16 arch.LinkArch = &x86.Link386
17 arch.REGSP = x86.REGSP
18 switch v := objabi.GO386; v {
19 case "387":
20 arch.Use387 = true
21 arch.SSAGenValue = ssaGenValue387
22 arch.SSAGenBlock = ssaGenBlock387
23 case "sse2":
24 arch.SSAGenValue = ssaGenValue
25 arch.SSAGenBlock = ssaGenBlock
26 default:
27 fmt.Fprintf(os.Stderr, "unsupported setting GO386=%s\n", v)
28 gc.Exit(1)
29 }
30 arch.MAXWIDTH = (1 << 32) - 1
31
32 arch.ZeroRange = zerorange
33 arch.ZeroAuto = zeroAuto
34 arch.Ginsnop = ginsnop
35
36 arch.SSAMarkMoves = ssaMarkMoves
37}
8func Init() {
9 log.Println("cache begin")
10
11 log.Println("#1 GroupPlugins...")
12 GroupPlugins.Init()
13
14 log.Println("#2 GroupTemplates...")
15 GroupTemplates.Init()
16
17 log.Println("#3 HostGroupsMap...")
18 HostGroupsMap.Init()
19
20 log.Println("#4 HostMap...")
21 HostMap.Init()
22
23 log.Println("#5 TemplateCache...")
24 TemplateCache.Init()
25
26 log.Println("#6 Strategies...")
27 Strategies.Init(TemplateCache.GetMap())
28
29 log.Println("#7 HostTemplateIds...")
30 HostTemplateIds.Init()
31
32 log.Println("#8 ExpressionCache...")
33 ExpressionCache.Init()
34
35 log.Println("#9 MonitoredHosts...")
36 MonitoredHosts.Init()
37
38 log.Println("cache done")
39
40 go LoopInit()
41
42}
8func init() {
9 fmt.Printf("Map: %v\n", m)
10 info = fmt.Sprintf("OS: %s, Arch: %s", runtime.GOOS, runtime.GOARCH)
11}
68func init() {
69 lomLocker = make(nameLocker, cmn.MultiSyncMapCount)
70 lomLocker.init()
71 if logLvl, ok := cmn.CheckDebug(pkgName); ok {
72 glog.SetV(glog.SmoduleCluster, logLvl)
73 }
74}

Related snippets