juju/juju · service.go
go logo
func (s *Service) deserialize(data []byte) (common.Conf, error) {
	conf, err := deserialize(data, renderer)
	if err != nil {
		return conf, s.errorf(err, "failed to deserialize conf")
	}
	return conf, nil
}
Similar code snippets
1.
juju/juju · service.go
Match rating: 63.22% · See similar code snippets
go logo
func (s *Service) readConf() (common.Conf, error) {
	var conf common.Conf

	data, err := Cmdline{}.conf(s.Service.Name, s.DirName)
	if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
		return conf, s.errorf(err, "failed to read conf from systemd")
	} else if err != nil && strings.Contains(err.Error(), "No such file or directory") {
		// give another try to check if db service exists in /var/lib/juju/init.
		// this check can be useful for installing mongoDB during upgrade.
		data, err = Cmdline{}.conf(s.Service.Name, renderer.Join(s.FallBackDirName, s.Service.Name))
		if err != nil {
			return conf, s.errorf(err, "failed to read conf from systemd")
		} else {
			return common.Conf{}, nil
		}
	}

	conf, err = s.deserialize(data)
	if err != nil {
		return conf, errors.Trace(err)
	}
	return conf, nil
}
2.
sclasen/swfsm · fsm_context.go
Match rating: 61.67% · See similar code snippets
go logo
func (f *FSMContext) Deserialize(serialized string, data interface{}) {
	f.serialization.Deserialize(serialized, data)
}
3.
hyperledger/fabric · configtx_util.go
Match rating: 61.42% · See similar code snippets
go logo
func deserialize(serializedConf []byte) (*common.Config, error) {
	conf := &common.Config{}
	if err := proto.Unmarshal(serializedConf, conf); err != nil {
		return nil, err
	}
	return conf, nil
}
4.
mohae/joefriday · os_unix.go
Match rating: 55.82% · See similar code snippets
go logo
func Deserialize(p []byte) (*o.OS, error) {
	os := &o.OS{}
	err := json.Unmarshal(p, os)
	if err != nil {
		return nil, err
	}
	return os, nil
}
5.
mohae/joefriday · cpuutil_unix.go
Match rating: 52.78% · See similar code snippets
go logo
func Deserialize(p []byte) (*util.CPUUtil, error) {
	ut := &util.CPUUtil{}
	err := json.Unmarshal(p, ut)
	if err != nil {
		return nil, err
	}
	return ut, nil
}
6.
tehnerd/gnl2go · gnl2go.go
Match rating: 51.92% · See similar code snippets
go logo
func DeserializeSerDes(serdesType string, list []byte) (SerDes, error) {
	switch serdesType {
	case "U8Type":
		attr := new(U8Type)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "U16Type":
		attr := new(U16Type)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "U32Type":
		attr := new(U32Type)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "U64Type":
		attr := new(U64Type)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "I32Type":
		attr := new(I32Type)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "Net16Type":
		attr := new(Net16Type)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "Net32Type":
		attr := new(Net32Type)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "NulStringType":
		attr := new(NulStringType)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return attr, nil
	case "IgnoreType":
		attr := new(IgnoreType)
		return attr, nil
	case "BinaryType":
		attr := new(BinaryType)
		//binary always return nil, no point to check err != nil
		attr.Deserialize(list)
		return attr, nil
	/*
		XXX(tehnerd): dangerous assumption that we either have basic types (above) or it's
		a nested attribute's list. havent tested in prod yet
	*/
	default:
		atl, exists := ATLName2ATL[serdesType]
		if !exists {
			return nil, fmt.Errorf("serdes doesnt exists. type: %v\n", serdesType)
		}
		attr := CreateAttrListType(atl)
		err := attr.Deserialize(list)
		if err != nil {
			return nil, err
		}
		return &attr, nil
	}
	return nil, nil
}
7.
boj/redistore · redistore.go
Match rating: 50.57% · See similar code snippets
go logo
func (s GobSerializer) Deserialize(d []byte, ss *sessions.Session) error {
	dec := gob.NewDecoder(bytes.NewBuffer(d))
	return dec.Decode(&ss.Values)
}
8.
mohae/joefriday · uptime_unix.go
Match rating: 49.82% · See similar code snippets
go logo
func Deserialize(p []byte) (*up.Uptime, error) {
	var u up.Uptime
	err := json.Unmarshal(p, &u)
	if err != nil {
		return nil, err
	}
	return &u, nil
}
9.
coffeehc/logger · config.go
Match rating: 49.72% · See similar code snippets
go logo
func parseConfile(loggerConf string) *Config {
	defer func() {
		if r := recover(); r != nil {
			log.Printf("解析配置文件%s出错:%s\n", loggerConf, r)
		}
	}()
	//log.Printf("加载日志配置文件:%s\n", loggerConf)
	data, err := ioutil.ReadFile(loggerConf)
	if err != nil {
		//log.Printf("[警告]加载日志配置文件错误:%s\n", err)
	} else {
		conf := new(Config)
		err = yaml.Unmarshal(data, conf)
		if err != nil {
			log.Printf("加载日志配置文件失败:%s\n", err)
		}
		return conf
	}
	return nil
}
10.
juju/juju · service.go
Match rating: 49.58% · See similar code snippets
go logo
func (s *Service) setConf(conf common.Conf) error {
	if conf.IsZero() {
		s.Service.Conf = conf
		return nil
	}

	normalConf, data := s.normalize(conf)
	if err := s.validate(normalConf); err != nil {
		return errors.Trace(err)
	}

	s.Script = data
	s.Service.Conf = normalConf
	return nil
}