mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
143 lines
2.6 KiB
Plaintext
143 lines
2.6 KiB
Plaintext
snippet p
|
|
package ${1:main}
|
|
|
|
${2}
|
|
snippet i
|
|
import (
|
|
"${1}"
|
|
)
|
|
|
|
${2}
|
|
snippet t
|
|
type ${1} struct {
|
|
${2}
|
|
}
|
|
${3}
|
|
snippet ti
|
|
type ${1} interface {
|
|
${2}
|
|
}
|
|
${3}
|
|
snippet c
|
|
package `Filename()`
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type `toupper(substitute(expand("%:t"), ".go", "", ""))` struct {
|
|
*ctx.Message
|
|
*ctx.Context
|
|
}
|
|
|
|
func (`Filename()` *`toupper(substitute(expand("%:t"), ".go", "", ""))`) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server {
|
|
c.Caches = map[string]*ctx.Cache{}
|
|
c.Configs = map[string]*ctx.Config{}
|
|
|
|
s := new(`toupper(substitute(expand("%:t"), ".go", "", ""))`)
|
|
s.Context = c
|
|
return s
|
|
}
|
|
|
|
func (`Filename()` *`toupper(substitute(expand("%:t"), ".go", "", ""))`) Begin(m *ctx.Message, arg ...string) ctx.Server {
|
|
if `Filename()`.Context == Index {
|
|
Pulse = m
|
|
}
|
|
`Filename()`.Message = m
|
|
return `Filename()`
|
|
}
|
|
|
|
func (`Filename()` *`toupper(substitute(expand("%:t"), ".go", "", ""))`) Start(m *ctx.Message, arg ...string) bool {
|
|
`Filename()`.Message = m
|
|
return false
|
|
}
|
|
|
|
func (`Filename()` *`toupper(substitute(expand("%:t"), ".go", "", ""))`) Close(m *ctx.Message, arg ...string) bool {
|
|
switch `Filename()`.Context {
|
|
case m.Target():
|
|
case m.Source():
|
|
}
|
|
return true
|
|
}
|
|
|
|
var Pulse *ctx.Message
|
|
var Index = &ctx.Context{Name: "`Filename()`", Help: "${1}",
|
|
Caches: map[string]*ctx.Cache{},
|
|
Configs: map[string]*ctx.Config{},
|
|
Commands: map[string]*ctx.Command{},
|
|
}
|
|
|
|
func init() {
|
|
`Filename()` := &`toupper(substitute(expand("%:t"), ".go", "", ""))`{}
|
|
`Filename()`.Context = Index
|
|
ctx.Index.Register(Index, `Filename()`)
|
|
}
|
|
snippet cmd
|
|
"${1}": &ctx.Command{Name: "${2}", Help: "${3}", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) string {
|
|
${4}
|
|
return ""
|
|
}},
|
|
|
|
snippet conf
|
|
"${1}": &ctx.Config{Name: "${2}", Value: "${3}", Help: "${4}", Hand: func(m *ctx.Message, x *ctx.Config, arg ...string) string {
|
|
if len(arg) > 0 {
|
|
${5}
|
|
return arg[0]
|
|
}
|
|
return x.Value
|
|
}},
|
|
snippet cap
|
|
"${1}": &ctx.Cache{Name: "${2}", Value: "${3}", Help: "${4}", Hand: func(m *ctx.Message, x *ctx.Cache, arg ...string) string {
|
|
if len(arg) > 0 {
|
|
${5}
|
|
return arg[0]
|
|
}
|
|
return x.Value
|
|
}},
|
|
snippet v
|
|
var (
|
|
${1}
|
|
)
|
|
${2}
|
|
snippet m
|
|
func main() {
|
|
${1}
|
|
}
|
|
|
|
snippet h
|
|
func(w http.ResponseWriter, r *http.Request) {
|
|
${1}
|
|
})
|
|
snippet f
|
|
func${1}(${2}) ${3}{
|
|
${4}
|
|
}${5}
|
|
snippet (
|
|
(${1})${2}
|
|
snippet [
|
|
[${1}]${2}
|
|
snippet {
|
|
{${1}}${2}
|
|
snippet if
|
|
if ${1} {
|
|
${2}
|
|
}
|
|
${3}
|
|
snippet for
|
|
for ${1}{
|
|
${2}
|
|
}
|
|
${3}
|
|
snippet switch
|
|
switch ${1}{
|
|
case ${2}:
|
|
${3}
|
|
}
|
|
${4}
|
|
snippet select
|
|
select {
|
|
case ${1}:
|
|
${2}
|
|
}
|
|
${3}
|