本文整理汇总了Golang中encoding/gob.RegisterName函数的典型用法代码示例。如果您正苦于以下问题:Golang RegisterName函数的具体用法?Golang RegisterName怎么用?Golang RegisterName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegisterName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
gob.RegisterName("perm.Permission", Permission{})
gob.RegisterName("perm.PermissionSet", PermissionSet{})
gob.RegisterName("perm.Implication", Implication{})
gob.RegisterName("perm.ImplicationSet", ImplicationSet{})
gob.RegisterName("perm.Condition", Condition{})
}
开发者ID:hlandau,项目名称:degoutils,代码行数:7,代码来源:perm.go
示例2: init
func init() {
// implements error
gob.RegisterName("*udpapi.APIError", &APIError{})
// implements APIReply
gob.RegisterName("*udpapi.errorWrapper", &errorWrapper{})
// implements APIReply
gob.RegisterName("*udpapi.genericReply", &genericReply{})
}
开发者ID:kaoruAngel,项目名称:go-anidb,代码行数:8,代码来源:reply.go
示例3: init
func init() {
gob.RegisterName("monsti.NodeContextArgs", NodeContextArgs{})
gob.RegisterName("monsti.NodeContextRet", NodeContextRet{})
gob.RegisterName("monsti.RenderNodeArgs", RenderNodeArgs{})
gob.RegisterName("monsti.RenderNodeRet", RenderNodeRet{})
gob.Register(new(template.HTML))
gob.Register(new(htmlwidgets.RenderData))
}
开发者ID:Ali-Kabiri,项目名称:monsti,代码行数:8,代码来源:signals.go
示例4: init
func init() {
// register oauthmw stores for use by gob.encode/decode (ie various binary sessionmw.Store types)
gob.RegisterName("knq.oauthmw.Store", Store{})
gob.RegisterName("knq.oauthmw.StoreState", StoreState{})
// register oauthmw for use with jsonstore
//jsonstore.RegisterSchema("knq.oauthmw.Store", Store{})
//jsonstore.RegisterSchema("knq.oauthmw.StoreState", StoreState{})
}
开发者ID:knq,项目名称:oauthmw,代码行数:9,代码来源:store.go
示例5: init
func init() {
// To make it possible to save the inventory, all object types have to be registered with gob.
// Use strings of one character to save bandwidth.
// If the letter for a type is changed, it will be lost for all inventories using the type.
gob.RegisterName("P", &Potion{})
gob.RegisterName("W", &Weapon{})
gob.RegisterName("A", &Armor{})
gob.RegisterName("H", &Helmet{})
gob.RegisterName("S", &Scroll{})
}
开发者ID:xushiwei,项目名称:ephenation-server,代码行数:10,代码来源:ObjectList.go
示例6: init
func init() {
gob.RegisterName("conf_value_string", *(&ctypes.ConfigValueStr{}))
gob.RegisterName("conf_value_int", *(&ctypes.ConfigValueInt{}))
gob.RegisterName("conf_value_float", *(&ctypes.ConfigValueFloat{}))
gob.RegisterName("conf_value_bool", *(&ctypes.ConfigValueBool{}))
gob.RegisterName("conf_policy_node", cpolicy.NewPolicyNode())
gob.RegisterName("conf_data_node", &cdata.ConfigDataNode{})
gob.RegisterName("conf_policy_string", &cpolicy.StringRule{})
gob.RegisterName("conf_policy_int", &cpolicy.IntRule{})
gob.RegisterName("conf_policy_float", &cpolicy.FloatRule{})
gob.RegisterName("conf_policy_bool", &cpolicy.BoolRule{})
}
开发者ID:IRCody,项目名称:snap,代码行数:13,代码来源:session.go
示例7: init
func init() {
gob.RegisterName("AE", new(raft.AppendEntries))
gob.RegisterName("AP", new(raft.AppendReply))
gob.RegisterName("CE", new(raft.ClientEntry))
gob.RegisterName("VQ", new(raft.VoteRequest))
gob.RegisterName("VP", new(raft.VoteReply))
gob.RegisterName("SR", new(store.ReqRead))
gob.RegisterName("SW", new(store.ReqWrite))
gob.RegisterName("SC", new(store.ReqCaS))
gob.RegisterName("SD", new(store.ReqDelete))
}
开发者ID:critiqjo,项目名称:cs733,代码行数:11,代码来源:coder.go
示例8: RegisterComponentType
// Registers a new type of component with a factory to make it, it is expected to be called during initialization
// Name must be unique, component_data must be
func RegisterComponentType(name string, component_factory func() Component, data Data) (registered_type Type) {
// Not to be called after finalizing registration
if registration_finalized {
panic("component.RegisterComponentType called after component.FinalizeRegistration")
}
if component_factory == nil {
panic("component_factory is nil")
}
if data == nil {
panic("data is nil")
}
// See if this was already registered
if _, ok := name_to_registered_type_map[name]; ok {
panic(name + " was already Registered.")
}
// Return a new Type, but we can't give it a real value until FinalizeRegistration is called
registered_type = Type(new(int))
*registered_type = -1
// Store the name, type, and factory_data
name_to_registered_type_map[name] = registered_type
registered_type_name_list = append(registered_type_name_list, name)
temp_component_factories[name] = factory_data{component_factory: component_factory, data: data}
// Reserve some space
registered_initialize_types.AddNewRegistrationID()
registered_destroy_types.AddNewRegistrationID()
gob.RegisterName(name, data.(interface{}))
return
}
开发者ID:Popog,项目名称:misu,代码行数:34,代码来源:component.go
示例9: init
func init() {
var err error
MyNode.Host, err = os.Hostname()
if err != nil {
panic(err)
}
gob.RegisterName("NodeInfo", NodeInfo{})
}
开发者ID:peak6,项目名称:gmap,代码行数:8,代码来源:gmap.go
示例10: RegisterType
// 注册 Type
func (self *typeContainer) RegisterType(typ reflect.Type) {
realType := FromPtrType(typ)
realTypeHashCode := GetTypeInfo(realType).HashCode().String()
if self.mapper[realTypeHashCode] == nil {
self.mapper[realTypeHashCode] = realType
gob.RegisterName(realTypeHashCode, reflect.New(realType).Interface())
switch realType.Kind() {
case reflect.Array, reflect.Slice:
self.RegisterType(realType.Elem())
}
}
}
开发者ID:Berkaroad,项目名称:util,代码行数:13,代码来源:typecontainer.go
示例11: EmitSignal
// EmitSignal emits the named signal with given arguments and return
// value.
func (s *MonstiClient) EmitSignal(name string, args interface{},
retarg interface{}) error {
if s.Error != nil {
return s.Error
}
gob.RegisterName(name+"Ret", reflect.Zero(
reflect.TypeOf(retarg).Elem().Elem()).Interface())
gob.RegisterName(name+"Args", args)
var args_ struct {
Name string
Args []byte
}
buffer := &bytes.Buffer{}
enc := gob.NewEncoder(buffer)
err := enc.Encode(argWrap{args})
if err != nil {
return fmt.Errorf("service: Could not encode signal argumens: %v", err)
}
args_.Name = name
args_.Args = buffer.Bytes()
var ret [][]byte
err = s.RPCClient.Call("Monsti.EmitSignal", args_, &ret)
if err != nil {
return fmt.Errorf("service: Monsti.EmitSignal error: %v", err)
}
reflect.ValueOf(retarg).Elem().Set(reflect.MakeSlice(
reflect.TypeOf(retarg).Elem(), len(ret), len(ret)))
for i, answer := range ret {
buffer = bytes.NewBuffer(answer)
dec := gob.NewDecoder(buffer)
var ret_ argWrap
err = dec.Decode(&ret_)
if err != nil {
return fmt.Errorf("service: Could not decode signal return value: %v", err)
}
reflect.ValueOf(retarg).Elem().Index(i).Set(reflect.ValueOf(ret_.Wrap))
}
return nil
}
开发者ID:Ali-Kabiri,项目名称:monsti,代码行数:41,代码来源:monsti.go
示例12: register
func register(e interface{}, t reflect.Type) {
registerLock.Lock()
defer registerLock.Unlock()
defer func() {
recover() // The only panic that we can get is from trying to register a base type.
registered[t] = struct{}{} // Remember for next time.
}()
if _, exists := registered[t]; !exists {
registered[t] = struct{}{}
gob.RegisterName(fmt.Sprintf("ℳ%d", nextID), e)
nextID++
}
}
开发者ID:gordon,项目名称:biogo,代码行数:14,代码来源:morass.go
示例13: init
func init() {
var err error
mongo_server := os.Getenv("OPENSHIFT_MONGODB_DB_URL")
if mongo_server == "" {
db_session, err = mgo.Dial("localhost")
} else {
db_session, err = mgo.Dial(mongo_server + MONGO_DB_NAME)
}
if err != nil {
log.Print("db connection: ", err)
}
// register bson's ObjectId with the gob for cookie encoding
gob.Register(bson.ObjectId(""))
gob.RegisterName("app/models.Flash", &Flash{"", ""})
gob.RegisterName("app/models.Filter", &Filter{})
database = db_session.DB("").Name
Router = pat.New()
//create an index for the email field on the users collection
if err := db_session.DB(database).C("users").EnsureIndex(mgo.Index{
Key: []string{"email"},
Unique: true,
}); err != nil {
log.Print("context: ", err)
}
if err := db_session.DB(database).C("users").EnsureIndexKey("location"); err != nil {
log.Print("context: ", err)
}
if err := db_session.DB(database).C("users").EnsureIndexKey("country"); err != nil {
log.Print("context: ", err)
}
store = sessions.NewCookieStore([]byte("508a664e65427d3f91000001"))
if sentry, err = raven.NewClient(SENTRY_DSN); err != nil {
log.Print("could not connect to sentry: ", err)
}
loadTranslations()
}
开发者ID:vichetuc,项目名称:lov3lyme,代码行数:37,代码来源:context.go
示例14: init
func (webApp *webApplication) init() {
database, err := sql.Open("mysql", "root:[email protected]/rielpoker")
if err != nil {
panic(err)
}
gob.RegisterName("user", &users.User{})
webApp.db = database
webApp.store = sessions.NewCookieStore([]byte("something-very-secret"))
webApp.templ = template.Must(template.ParseGlob("/home/leebc/go/src/github.com/rp/src/poker2/views/templates/*")).Funcs(
template.FuncMap{
"eq": func(x, b bool) bool {
return x == b
},
})
}
开发者ID:patrickjr,项目名称:poker2,代码行数:15,代码来源:main.go
示例15: TestSerializeDecoder
func TestSerializeDecoder(t *testing.T) {
println("serialize decoder test start")
loc := MediaLocator{Filename: "../../../target/dependency/fixtures/testfile.flv"}
source := DataSource{Locator: loc}
result := source.Connect()
if result != nil {
t.Fatalf("cold not open file : %s", loc.Filename)
}
plex := NewDemultiplexer(&source)
//tracks:=plex.GetTracks()
tracks := plex.GetTracks()
for i := 0; i < len(tracks); i++ {
dec := tracks[i].GetDecoder()
//dec.Open()
params := dec.GetParameters()
dec2 := Decoder{}
for k, v := range params {
dec2.SetParameter(k, v)
}
dec2.Open()
gob.RegisterName("NewTypeObject", Packet{})
b := new(bytes.Buffer)
enc := gob.NewEncoder(b)
err := enc.Encode(dec)
if err != nil {
fmt.Printf("%s\n", err)
//return err
break
}
bdec := gob.NewDecoder(b)
err = bdec.Decode(dec)
if err != nil {
fmt.Printf("%s\n", err)
break
//return err
}
}
println("serialize decoder test finished")
}
开发者ID:psychobob666,项目名称:gmf,代码行数:43,代码来源:Decoder_test.go
示例16: init
/* Register all types */
func init() {
gob.RegisterName("service.HelloMsg", HelloMsg{})
gob.RegisterName("service.AuthenticateMsg", AuthenticateMsg{})
gob.RegisterName("service.AuthenticationFailedMsg", AuthenticationFailedMsg{})
gob.RegisterName("service.AuthenticationSucceededMsg", AuthenticationSucceededMsg{})
gob.RegisterName("service.ConnectDeviceApprovedMsg", ConnectDeviceApprovedMsg{})
gob.RegisterName("service.ConnectDeviceDeclinedMsg", ConnectDeviceDeclinedMsg{})
gob.RegisterName("service.ConnectDeviceMsg", ConnectDeviceMsg{})
gob.RegisterName("service.DisconnectDeviceMsg", DisconnectDeviceMsg{})
gob.RegisterName("service.GetRFAddrMsg", GetRFAddrMsg{})
gob.RegisterName("service.GetTimeMsg", GetTimeMsg{})
gob.RegisterName("service.GetTypeMsg", GetTypeMsg{})
gob.RegisterName("service.HelloMsg", HelloMsg{})
gob.RegisterName("service.JoinRequestApprovedMsg", JoinRequestApprovedMsg{})
gob.RegisterName("service.JoinRequestDeclinedMsg", JoinRequestDeclinedMsg{})
gob.RegisterName("service.JoinRequestMsg", JoinRequestMsg{})
gob.RegisterName("service.JoinRequestPendingMsg", JoinRequestPendingMsg{})
gob.RegisterName("service.MoveDeviceMsg", MoveDeviceMsg{})
gob.RegisterName("service.NoTypeMsg", NoTypeMsg{})
gob.RegisterName("service.RFAddrMsg", RFAddrMsg{})
gob.RegisterName("service.RawSensorData", RawSensorData{})
gob.RegisterName("service.SensorDataMsg", SensorDataMsg{})
gob.RegisterName("service.SensorDataSyncedMsg", SensorDataSyncedMsg{})
gob.RegisterName("service.ServerMessage", ServerMessage{})
gob.RegisterName("service.TimeMsg", TimeMsg{})
gob.RegisterName("service.TypeMsg", TypeMsg{})
}
开发者ID:botanist,项目名称:api,代码行数:28,代码来源:protocol.go
示例17: init
func init() {
// implements APIReply
gob.RegisterName("*udpapi.UptimeReply", &UptimeReply{})
// implements APIReply
gob.RegisterName("*udpapi.PingReply", &PingReply{})
}
开发者ID:kaoruAngel,项目名称:go-anidb,代码行数:6,代码来源:misc.go
示例18: init
func init() {
gob.RegisterName("NameServiceAddInodeRequest", &NameServiceAddInodeRequest{})
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:3,代码来源:nameservicerpc.go
示例19: init
func init() {
// Register the types we'll need when we add them to our auth
// cookies.
gob.RegisterName("main.User", &User{})
}
开发者ID:EricLagergren,项目名称:pnwconference,代码行数:5,代码来源:models.go
示例20: init
func init() {
gob.RegisterName("main.CrawlingEntry", CrawlingEntry{})
}
开发者ID:xavieryang007,项目名称:gcse,代码行数:3,代码来源:crawler.go
注:本文中的encoding/gob.RegisterName函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论