Documentation ¶
Overview ¶
Package trygo implements a simple library demos the package useage..
Index ¶
- Constants
- Variables
- func Append(slice []int, element int) []int
- func Cat()
- func Crawl(url string, depth int, fetcher Fetcher)
- func DNSLookup()
- func Decode(s string) (ret string)
- func DecodeS(s string) (ret string)
- func DemoArgs()
- func DemoBase64()
- func DemoBig()
- func DemoBinary()
- func DemoBufio()
- func DemoCalc()
- func DemoChan()
- func DemoChannel()
- func DemoChannel2()
- func DemoChannel3()
- func DemoChannel4()
- func DemoChannel5()
- func DemoClosure()
- func DemoConst()
- func DemoCustomtype()
- func DemoDefer()
- func DemoDefine()
- func DemoDeleteItem()
- func DemoError()
- func DemoExec()
- func DemoExec2()
- func DemoExec3()
- func DemoFile() error
- func DemoFor()
- func DemoForrange()
- func DemoFunc()
- func DemoFunc2()
- func DemoFuncchan()
- func DemoFuncvalue()
- func DemoGetenv()
- func DemoGoroutine()
- func DemoGoroutine2()
- func DemoGoto()
- func DemoHTTP()
- func DemoHTTP2()
- func DemoHTTPJson()
- func DemoHTTPServ()
- func DemoIf()
- func DemoImage()
- func DemoImage2()
- func DemoImage3()
- func DemoImage4()
- func DemoInterface()
- func DemoInterface2()
- func DemoInterface3()
- func DemoInterfaceRecurve()
- func DemoIntrospection()
- func DemoIo()
- func DemoIo2()
- func DemoIo3()
- func DemoIo4()
- func DemoJSON()
- func DemoJSON2()
- func DemoJSON3()
- func DemoJSON4()
- func DemoMap()
- func DemoMap1()
- func DemoMap2()
- func DemoMap3()
- func DemoMethod()
- func DemoMethod2()
- func DemoMime()
- func DemoMongo()
- func DemoMysql()
- func DemoNet()
- func DemoPackage()
- func DemoPanic()
- func DemoPipe()
- func DemoPkg()
- func DemoPointer()
- func DemoQueue()
- func DemoRef()
- func DemoReflect()
- func DemoReflection()
- func DemoReflection2()
- func DemoReflection3()
- func DemoRefs()
- func DemoRegexp()
- func DemoRegexp2()
- func DemoSendMail()
- func DemoSet()
- func DemoSignal()
- func DemoSlice()
- func DemoSlice2()
- func DemoSocket()
- func DemoSort()
- func DemoSort2()
- func DemoSortAny()
- func DemoSplit()
- func DemoStack()
- func DemoString()
- func DemoStruct()
- func DemoSwitch()
- func DemoSync()
- func DemoSync2()
- func DemoSync3()
- func DemoSync4()
- func DemoTabwriter()
- func DemoTime()
- func DemoType()
- func DemoType2()
- func DemoTypeRecursive()
- func DemoVararg2()
- func DemoVarargs()
- func DemoXlsx()
- func DoubleExtend(slice []int) []int
- func DrawLine(img *image.RGBA, x1, y1, x2, y2 int, color color.Color)
- func Echo(c net.Conn)
- func EchoServer()
- func Encode(s string) (ret string)
- func EncodeS(s string) (ret string)
- func Even(i int) bool
- func EventLoop()
- func ExerciseChecktree()
- func ExerciseCraw()
- func ExerciseError()
- func ExerciseFibonacci()
- func ExerciseFunctions()
- func ExerciseIoreader()
- func ExerciseSqrt()
- func ExerciseWc()
- func FakeTime()
- func Fingerd()
- func Map(f func(int) int, l []int) []int
- func Markov()
- func OnclickButton1(c Control)
- func OnloadApplication(c Control)
- func OnloadForm1(c Control)
- func OnoverButton1(c Control)
- func OnoverCheckbox1(c Control)
- func Permrec()
- func Psgrp()
- func SendMail(user, password, host, to, subject, body, mailtype string) error
- func ShowImage(filename string)
- func ShowTag(i interface{})
- func Sort(x Sorter)
- func Sqrt(x float64) float64
- func SqrtE(f float64) (float64, error)
- func Uniq()
- func Wc()
- type Abser
- type AddressBook
- type Application
- type Blogs
- type Button
- type ByAge
- type Chain
- type Checkbox
- type Control
- type E
- type ErrNegativeSqrt
- type Fetcher
- type Form
- type Hello
- type I
- type Interface1
- type Interface2
- type Item
- type MyError
- type MyFloat
- type MyString
- type MyStruct
- type NameAge
- type Payload
- type Person
- type Prefix
- type Queue
- type R
- type ReadWriter
- type Reader
- type S
- type Score
- type SearchTreeNode
- type Sorter
- type Stack
- type SyncedBuffer
- type T
- type TestMysql
- type Tree
- type UserDef
- type Users
- type Vertex
- type Writer
- type Xi
- type Xs
Constants ¶
const ( // Big int Big = 1 << 60 // Small int Small = Big >> 59 )
const ( // Enone const Enone = 1 // Einval const Einval = 2 )
const ( CLICK = iota DCLICK EXIT LOAD OVER )
control Application, Yeah!!! Application is control too.
const ( ADD SUB MUL DIV MAXPOS = 11 )
Some operator
const Pi = 3.14
Pi math
Variables ¶
var MorseTable = map[byte]string{
'A': ".- ",
'B': "-... ",
'C': "-.-. ",
'D': "-.. ",
'E': ". ",
'F': "..-. ",
'G': "--. ",
'H': ".... ",
'I': ".. ",
'J': ".--- ",
'K': "-.- ",
'L': ".-.. ",
'M': "-- ",
'N': "-. ",
'O': "--- ",
'P': ".--. ",
'Q': "--.- ",
'R': ".-. ",
'S': "... ",
'T': "- ",
'U': "..- ",
'V': "...- ",
'W': ".-- ",
'X': "-..- ",
'Y': "-.-- ",
'Z': "--.. ",
'0': "----- ",
'1': ".---- ",
'2': "..--- ",
'3': "...-- ",
'4': "....- ",
'5': "..... ",
'6': "-.... ",
'7': "--... ",
'8': "---.. ",
'9': "----. ",
}
MorseTable data
var MorseTableS = map[byte]string{
'1': ".- ",
'2': "..- ",
'3': "...- ",
'4': "....- ",
'5': ". ",
'6': "-.... ",
'7': "-... ",
'8': "-.. ",
'9': "-. ",
'0': "- ",
}
MorseTableS data
Functions ¶
func DemoBinary ¶
func DemoBinary()
func EchoServer ¶
func EchoServer()
EchoServer func Usage
$ ./test # server side $ nc 127.0.0.1 8053 # client side abc abc
true loop by default!
func OnclickButton1 ¶
func OnclickButton1(c Control)
OnclickButton1 user customized event callback functions
func OnloadApplication ¶
func OnloadApplication(c Control)
OnloadApplication user programming entry OnloadApplication()
func SendMail ¶
SendMail func user : example@example.com login smtp server user password: xxxxx login smtp server password host: smtp.example.com:port smtp.163.com:25 to: example@example.com;example1@163.com;example2@sina.com.cn;... subject:The subject of mail body: The content of mail mailtyoe: mail type html or text
Types ¶
type Application ¶
type Application struct { Text string Objects map[string]Control Bindings map[eventkey]func(Control) }
Application struct
func (Application) Add ¶
func (a Application) Add(objid string, c Control)
Add target control to application, LOAD event generated either
func (Application) Binding ¶
func (a Application) Binding(objid string, eventid int, op func(Control))
Binding (object, event) with process function
func (Application) Event ¶
func (a Application) Event(objid string, eventid int)
Event process event will cause callback function executed
type Blogs ¶
type Blogs struct { ID int User Users Title string Description string Modified string Published bool Taglist []string }
Blogs struct
type ByAge ¶
type ByAge []person
ByAge implements sort.Interface for []person based on the Age field.
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain contains a map ("chain") of prefixes to a list of suffixes. A prefix is a string of prefixLen words joined with spaces. A suffix is a single word. A prefix can have multiple suffixes.
type Control ¶
type Control interface {
Tostring() string
}
Control is the base interface of all control types
type Fetcher ¶
type Fetcher interface { // Fetch 返回 URL 的 body 内容,并且将在这个页面上找到的 URL 放到一个 slice 中。 Fetch(url string) (body string, urls []string, err error) }
Fetcher interface
type Interface2 ¶
type Interface2 interface { Interface1 Push(x interface{}) Pop() interface{} }
Interface2 interface
type Prefix ¶
type Prefix []string
Prefix is a Markov chain prefix of one or more words.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue struct
type SearchTreeNode ¶
type SearchTreeNode struct { Chars []rune Children []*SearchTreeNode End bool }
func NewSearchTree ¶
func NewSearchTree() *SearchTreeNode
func (*SearchTreeNode) Add ¶
func (n *SearchTreeNode) Add(word string)
func (*SearchTreeNode) Contain ¶
func (n *SearchTreeNode) Contain(word string) (ret bool)
func (*SearchTreeNode) Print ¶
func (n *SearchTreeNode) Print()
type SyncedBuffer ¶
type SyncedBuffer struct {
// contains filtered or unexported fields
}
SyncedBuffer struct
type TestMysql ¶
type TestMysql struct {
// contains filtered or unexported fields
}
TestMysql struct
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
demos
|
|
demo_algorithms
3.7 Bernoulli test A test throw corn N times, see how many times gets the front side.
|
3.7 Bernoulli test A test throw corn N times, see how many times gets the front side. |
demo_closure_recursion
Closure recursion
|
Closure recursion |
demo_map
https://blog.golang.org/go-maps-in-action
|
https://blog.golang.org/go-maps-in-action |
demo_pg
Manuals ======= Install DB ---------- pi@host$ sudo apt-get install postgresql Create database and its account ------------------------------- Notice: user/password must match exist accounts in OS !!! pi@host$ sudo -u postgres psql -U postgres CREATE USER pi WITH PASSWORD 'xxxxxx'; CREATE DATABASE snsrobot; GRANT ALL PRIVILEGES ON DATABASE snsrobot TO pi; \q # raspbian with raspberry pi 2: pi@host$ sudo -u postgres cat <<_END >>/var/lib/postgresql/data/pg_hba.conf # ubuntu: pi@host$ #sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/pg_hba.conf host all "pi" 0.0.0.0/0 trust _END pi@host$ sudo service postgresql restart Create tables in host --------------------- pi@host$ psql snsrobot snsrobot => CREATE TABLE userinfo ( uid serial NOT NULL, username character varying(100) NOT NULL, departname character varying(500) NOT NULL, Created date, CONSTRAINT userinfo_pkey PRIMARY KEY (uid) ) WITH (OIDS=FALSE); snsrobot => \q Configure the remote access --------------------------- pi@host$ sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/postgresql.conf listen_addresses='*' _END pi@host$ sudo service postgresql restart user@client$ psql -h 192.168.1.109 -U pi -W -d snsrobot Usage Example ------------- user@client$ go build user@client$ ./testpg.exe -c pi:xxxxx@192.168.1.109/snsrobot [Demo program]: http://astaxie.gitbooks.io/build-web-application-with-golang/content/en/05.4.html [Remote access]: http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
|
Manuals ======= Install DB ---------- pi@host$ sudo apt-get install postgresql Create database and its account ------------------------------- Notice: user/password must match exist accounts in OS !!! pi@host$ sudo -u postgres psql -U postgres CREATE USER pi WITH PASSWORD 'xxxxxx'; CREATE DATABASE snsrobot; GRANT ALL PRIVILEGES ON DATABASE snsrobot TO pi; \q # raspbian with raspberry pi 2: pi@host$ sudo -u postgres cat <<_END >>/var/lib/postgresql/data/pg_hba.conf # ubuntu: pi@host$ #sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/pg_hba.conf host all "pi" 0.0.0.0/0 trust _END pi@host$ sudo service postgresql restart Create tables in host --------------------- pi@host$ psql snsrobot snsrobot => CREATE TABLE userinfo ( uid serial NOT NULL, username character varying(100) NOT NULL, departname character varying(500) NOT NULL, Created date, CONSTRAINT userinfo_pkey PRIMARY KEY (uid) ) WITH (OIDS=FALSE); snsrobot => \q Configure the remote access --------------------------- pi@host$ sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/postgresql.conf listen_addresses='*' _END pi@host$ sudo service postgresql restart user@client$ psql -h 192.168.1.109 -U pi -W -d snsrobot Usage Example ------------- user@client$ go build user@client$ ./testpg.exe -c pi:xxxxx@192.168.1.109/snsrobot [Demo program]: http://astaxie.gitbooks.io/build-web-application-with-golang/content/en/05.4.html [Remote access]: http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html |
demo_pg_json
Manuals ======= Install DB ---------- pi@host$ sudo apt-get install postgresql Create database and its account ------------------------------- Notice: user/password must match exist accounts in OS !!! pi@host$ sudo -u postgres psql -U postgres CREATE USER pi WITH PASSWORD 'xxxxxx'; CREATE DATABASE snsrobot; GRANT ALL PRIVILEGES ON DATABASE snsrobot TO pi; \q # raspbian with raspberry pi 2: pi@host$ sudo -u postgres cat <<_END >>/var/lib/postgresql/data/pg_hba.conf # ubuntu: pi@host$ #sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/pg_hba.conf host all "pi" 0.0.0.0/0 trust _END pi@host$ sudo service postgresql restart Create tables in host --------------------- pi@host$ psql snsrobot snsrobot => CREATE TABLE userinfo ( uid serial NOT NULL, username character varying(100) NOT NULL, departname character varying(500) NOT NULL, Created date, CONSTRAINT userinfo_pkey PRIMARY KEY (uid) ) WITH (OIDS=FALSE); snsrobot => \q Configure the remote access --------------------------- pi@host$ sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/postgresql.conf listen_addresses='*' _END pi@host$ sudo service postgresql restart user@client$ psql -h 192.168.1.109 -U pi -W -d snsrobot Usage Example ------------- user@client$ go build user@client$ ./testpg.exe -c pi:xxxxx@192.168.1.109/snsrobot [Demo program]: http://astaxie.gitbooks.io/build-web-application-with-golang/content/en/05.4.html [Remote access]: http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
|
Manuals ======= Install DB ---------- pi@host$ sudo apt-get install postgresql Create database and its account ------------------------------- Notice: user/password must match exist accounts in OS !!! pi@host$ sudo -u postgres psql -U postgres CREATE USER pi WITH PASSWORD 'xxxxxx'; CREATE DATABASE snsrobot; GRANT ALL PRIVILEGES ON DATABASE snsrobot TO pi; \q # raspbian with raspberry pi 2: pi@host$ sudo -u postgres cat <<_END >>/var/lib/postgresql/data/pg_hba.conf # ubuntu: pi@host$ #sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/pg_hba.conf host all "pi" 0.0.0.0/0 trust _END pi@host$ sudo service postgresql restart Create tables in host --------------------- pi@host$ psql snsrobot snsrobot => CREATE TABLE userinfo ( uid serial NOT NULL, username character varying(100) NOT NULL, departname character varying(500) NOT NULL, Created date, CONSTRAINT userinfo_pkey PRIMARY KEY (uid) ) WITH (OIDS=FALSE); snsrobot => \q Configure the remote access --------------------------- pi@host$ sudo -u postgres cat <<_END >>/etc/postgresql/9.4/main/postgresql.conf listen_addresses='*' _END pi@host$ sudo service postgresql restart user@client$ psql -h 192.168.1.109 -U pi -W -d snsrobot Usage Example ------------- user@client$ go build user@client$ ./testpg.exe -c pi:xxxxx@192.168.1.109/snsrobot [Demo program]: http://astaxie.gitbooks.io/build-web-application-with-golang/content/en/05.4.html [Remote access]: http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html |
demo_redis
Demon for manage connection pool of redis.
|
Demon for manage connection pool of redis. |
demo_runtemplate
Install `runtemplate` by `go get github.com/flowonyx/runtemplate`.
|
Install `runtemplate` by `go get github.com/flowonyx/runtemplate`. |
demo_service
simple does nothing except block while running the service.
|
simple does nothing except block while running the service. |
demo_tmp
http://blog.studygolang.com/2013/01/go%E5%8A%A0%E5%AF%86%E8%A7%A3%E5%AF%86%E4%B9%8Brsa/ 密钥长度,1024觉得不够安全的话可以用2048,但是代价也相应增大 openssl genrsa -out private.pem 1024 用于生成密钥。
|
http://blog.studygolang.com/2013/01/go%E5%8A%A0%E5%AF%86%E8%A7%A3%E5%AF%86%E4%B9%8Brsa/ 密钥长度,1024觉得不够安全的话可以用2048,但是代价也相应增大 openssl genrsa -out private.pem 1024 用于生成密钥。 |
tools
|
|