all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
9
Task/Singleton/Go/singleton-1.go
Normal file
9
Task/Singleton/Go/singleton-1.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package singlep
|
||||
|
||||
// package level data declarations serve as singleton instance variables
|
||||
var X, Y int
|
||||
|
||||
// package level functions serve as methods for a package-as-a-singleton
|
||||
func F() int {
|
||||
return Y - X
|
||||
}
|
||||
14
Task/Singleton/Go/singleton-2.go
Normal file
14
Task/Singleton/Go/singleton-2.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"singlep"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// dot selector syntax references package variables and functions
|
||||
singlep.X = 2
|
||||
singlep.Y = 3
|
||||
fmt.Println(singlep.X, singlep.Y)
|
||||
fmt.Println(singlep.F())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue