本文整理汇总了Golang中code/google/com/p/goprotobuf/proto.Int32函数的典型用法代码示例。如果您正苦于以下问题:Golang Int32函数的具体用法?Golang Int32怎么用?Golang Int32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Int32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: signProto
func signProto(day int) []*protodata.RewardData {
var result []*protodata.RewardData
Lua, _ := lua.NewLua("conf/sign_reward.lua")
begin := day/7 - 1
if begin < 0 {
begin = 0
}
begin = begin*7 + 1
for i := begin; i <= begin+7; i++ {
//Lua.L.GetGlobal("signReward")
Lua.L.DoString(fmt.Sprintf("coin, diamond, action, generalId = signReward(%d)", i))
coin := Lua.GetInt("coin")
diamond := Lua.GetInt("diamond")
action := Lua.GetInt("action")
generalId := Lua.GetInt("generalId")
temp := new(protodata.RewardData)
temp.RewardCoin = proto.Int32(int32(coin))
temp.RewardDiamond = proto.Int32(int32(diamond))
temp.Stamina = proto.Int32(int32(action))
if generalId > 0 {
config := models.BaseGeneral(generalId, nil)
temp.General = generalProto(new(models.GeneralData), config)
}
result = append(result, temp)
}
Lua.Close()
return result
}
示例2: ExampleBytesPerDevice_missingFlow
func ExampleBytesPerDevice_missingFlow() {
trace := Trace{
PacketSeries: []*PacketSeriesEntry{
&PacketSeriesEntry{
TimestampMicroseconds: proto.Int64(0),
Size: proto.Int32(10),
FlowId: proto.Int32(4),
},
},
}
consistentRanges := []*store.Record{
&store.Record{
Key: lex.EncodeOrDie("node0", "anon0", int64(0), int32(0)),
Value: lex.EncodeOrDie("node0", "anon0", int64(0), int32(0)),
},
}
records := map[string]Trace{
string(lex.EncodeOrDie("node0", "anon0", int64(0), int32(0))): trace,
}
runBytesPerDevicePipeline(consistentRanges, records)
fmt.Printf("No output")
// Output:
// No output
}
示例3: SendBussiness
func (self *Client) SendBussiness(ziptype int32, datatype int32, data []byte) (uint64, string) {
fun := "Client.SendBussiness"
msgid, err := self.manager.Msgid()
if err != nil {
slog.Errorf("%s get msgid error:%s", fun, err)
return 0, self.remoteaddr
}
buss := &pushproto.Talk{
Type: pushproto.Talk_BUSSINESS.Enum(),
Msgid: proto.Uint64(msgid),
Ziptype: proto.Int32(ziptype),
Datatype: proto.Int32(datatype),
Bussdata: data,
}
spb, err := proto.Marshal(buss)
if err != nil {
slog.Errorf("%s marshaling error: ", fun, err)
return 0, self.remoteaddr
}
p := util.Packdata(spb)
self.sendBussRetry(msgid, p)
slog.Infof("%s client:%s send msgid:%d", fun, self, msgid)
self.Send(p)
return msgid, self.remoteaddr
}
示例4: MakeImport
func MakeImport(path string, lineNum int32) *Instruction {
return &Instruction{
Type: pb.Int32(constants.Instruction_IMPORT),
Value: pb.String(path),
LineNumber: pb.Int32(lineNum),
}
}
示例5: MakeComment
func MakeComment(comment string, lineNum int32) *Instruction {
return &Instruction{
Type: pb.Int32(constants.Instruction_COMMENT),
Value: pb.String(comment),
LineNumber: pb.Int32(lineNum),
}
}
示例6: init
func init() {
netlib.RegisterHandler(int(protocol.CoreBuiltinPacketID_PACKET_SS_SLICES), &PacketSlicesHandler{})
netlib.RegisterFactory(int(protocol.CoreBuiltinPacketID_PACKET_SS_SLICES), &PacketSlicesPacketFactory{})
netlib.DefaultBuiltinProtocolEncoder.PacketCutor = func(data []byte) (packs []interface{}) {
var (
offset = 0
sendSize = 0
seqNo = 1
totalSize = len(data)
restSize = len(data)
)
for restSize > 0 {
sendSize = restSize
if sendSize > netlib.MaxPacketSize-128 {
sendSize = netlib.MaxPacketSize - 128
}
pack := &protocol.SSPacketSlices{
SeqNo: proto.Int32(int32(seqNo)),
TotalSize: proto.Int32(int32(totalSize)),
Offset: proto.Int32(int32(offset)),
PacketData: data[offset : offset+sendSize],
}
proto.SetDefaults(pack)
seqNo++
restSize -= sendSize
offset += sendSize
packs = append(packs, pack)
}
return
}
}
示例7: resolveNativeDeclaration
// can't re-use the legacy native function resolver because it's a method of a
// type that provides its own helpers and contextual data, all of which would
// be too hard to reproduce
func (pkgr *Packager) resolveNativeDeclaration(f *tp.Function, path string) {
// first we should check that the signature refers to something that actually exists
sigStr := strings.Replace(f.Stub(pkgr.Package), ",", ".", -1)
if whale.LookupBuiltIn(sigStr) == nil {
panic(fmt.Sprintf("attempt to provide signature for nonexistent native function `%s` in `%s`", sigStr, path))
}
// now turn the type names into the appropriate numeric ids
if returnType := f.GetReturnType(); len(returnType) > 0 {
f.ReturnTypeId = proto.Int32(int32(pkgr.TypeMap[returnType]))
f.ReturnType = nil
}
if scopeType := f.GetScopeType(); len(scopeType) > 0 {
f.ScopeTypeId = proto.Int32(int32(pkgr.TypeMap[scopeType]))
f.ScopeType = nil
}
if opensType := f.GetOpensType(); len(opensType) > 0 {
f.OpensTypeId = proto.Int32(int32(pkgr.TypeMap[opensType]))
f.OpensType = nil
}
for _, arg := range f.Args {
if typeName := arg.GetTypeString(); len(typeName) > 0 {
arg.TypeId = proto.Int32(int32(pkgr.TypeMap[typeName]))
arg.TypeString = nil
}
}
}
示例8: resolveHeader
func (pkg *Package) resolveHeader(function *tp.Function) {
returnType := null.GetString(function.ReturnType)
if len(returnType) > 0 {
function.ReturnTypeId = proto.Int32(int32(pkg.findTypeIndex(returnType)))
function.ReturnType = nil
}
scopeType := null.GetString(function.ScopeType)
if len(scopeType) > 0 {
function.ScopeTypeId = proto.Int32(int32(pkg.findTypeIndex(scopeType)))
function.ScopeType = nil
}
opensType := null.GetString(function.OpensType)
if len(opensType) > 0 {
function.OpensTypeId = proto.Int32(int32(pkg.findTypeIndex(opensType)))
function.OpensType = nil
}
for _, arg := range function.Args {
typeName := null.GetString(arg.TypeString)
if len(typeName) > 0 {
arg.TypeId = proto.Int32(int32(pkg.findTypeIndex(typeName)))
arg.TypeString = nil
}
}
}
示例9: TestParseSectionIntro_Valid
func TestParseSectionIntro_Valid(t *testing.T) {
lines := []string{
"10",
"BUILDID",
"NODEID 123 321 789",
"12 23 34",
}
trace := Trace{}
err := parseSectionIntro(lines, &trace)
if err != nil {
t.Fatal("Unexpected error:", err)
}
expectedTrace := Trace{
FileFormatVersion: proto.Int32(10),
BuildId: proto.String("BUILDID"),
NodeId: proto.String("NODEID"),
ProcessStartTimeMicroseconds: proto.Int64(123),
SequenceNumber: proto.Int32(321),
TraceCreationTimestamp: proto.Int64(789),
PcapReceived: proto.Uint32(12),
PcapDropped: proto.Uint32(23),
InterfaceDropped: proto.Uint32(34),
}
checkProtosEqual(t, &expectedTrace, &trace)
}
示例10: MakeBlock
func MakeBlock(children []*Instruction, lineNum int32) *Instruction {
return &Instruction{
Type: pb.Int32(constants.Instruction_BLOCK),
Children: children,
LineNumber: pb.Int32(lineNum),
}
}
示例11: ReadRewriteRules
func ReadRewriteRules(rules []string) []*RewriteRule {
if ruleNum := len(rules); ruleNum/4 > 0 {
rrules := make([]*RewriteRule, 0, ruleNum/4)
for i := 0; i < ruleNum/4; i++ {
newRule := &RewriteRule{}
newRule.Proxy = new(string)
newRule.Upstream = new(string)
newRule.CookieDomain = new(string)
direction := rules[4*i]
*(newRule.Proxy) = rules[4*i+1]
*(newRule.Upstream) = rules[4*i+2]
*(newRule.CookieDomain) = rules[4*i+3]
if direction == RuleToProxy {
newRule.Direction = pb.Int32(constants.RewriteRule_UPSTREAM_TO_PROXY)
} else if direction == RuleToUpstream {
newRule.Direction = pb.Int32(constants.RewriteRule_PROXY_TO_UPSTREAM)
} else {
newRule.Direction = pb.Int32(constants.RewriteRule_BIDIRECTIONAL)
}
rrules = append(rrules, newRule)
}
return rrules
}
return nil
}
示例12: insert
// Insert can insert record into a btree
func (t *Btree) insert(record TreeLog) error {
tnode, err := t.getTreeNode(t.GetRoot())
if err != nil {
if err.Error() != "no data" {
return err
}
nnode := t.newTreeNode()
nnode.NodeType = proto.Int32(isLeaf)
_, err = nnode.insertRecord(record, t)
if err == nil {
t.Nodes[nnode.GetId()], err = proto.Marshal(nnode)
}
t.Root = proto.Int64(nnode.GetId())
return err
}
clonednode, err := tnode.insertRecord(record, t)
if err == nil && len(clonednode.GetKeys()) > int(t.GetNodeMax()) {
nnode := t.newTreeNode()
nnode.NodeType = proto.Int32(isNode)
key, left, right := clonednode.split(t)
nnode.insertOnce(key, left, right, t)
t.Nodes[nnode.GetId()], err = proto.Marshal(nnode)
t.Root = proto.Int64(nnode.GetId())
} else {
t.Root = proto.Int64(clonednode.GetId())
}
return err
}
示例13: MakeText
func MakeText(text string, lineNum int32) *Instruction {
return &Instruction{
Type: pb.Int32(constants.Instruction_TEXT),
Value: pb.String(text),
LineNumber: pb.Int32(lineNum),
}
}
示例14: MakePosition
func MakePosition(pos string, lineNum int32) *Instruction {
return &Instruction{
Type: pb.Int32(constants.Instruction_POSITION),
Value: pb.String(pos),
LineNumber: pb.Int32(lineNum),
}
}
示例15: rewardProto
func rewardProto(coin, diamond, actionValue int, generalData *protodata.GeneralData) *protodata.RewardData {
return &protodata.RewardData{
RewardCoin: proto.Int32(int32(coin)),
RewardDiamond: proto.Int32(int32(diamond)),
Stamina: proto.Int32(int32(actionValue)),
General: generalData}
}