代码拉取完成,页面将自动刷新
// Copyright 2015 go-smpp authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package pdutlv
import (
"fmt"
)
// Map is a collection of PDU TLV field data indexed by tag.
type Map map[Tag]Body
// Set updates the PDU map with the given tag and value, and
// returns error if the value cannot be converted to type Data.
//
// This is a shortcut for m[t] = NewTLV(t, v) converting v properly.
func (m Map) Set(t Tag, v interface{}) error {
switch v.(type) {
case nil:
m[t] = NewTLV(t, nil) // use default value
case uint8:
m[t] = NewTLV(t, []byte{v.(uint8)})
case int:
m[t] = NewTLV(t, []byte{uint8(v.(int))})
case string:
m[t] = NewTLV(t, []byte(v.(string)))
case String:
m[t] = NewTLV(t, []byte(v.(String)))
case CString:
value := []byte(v.(CString))
if len(value) == 0 || value[len(value)-1] != 0x00 {
value = append(value, 0x00)
}
m[t] = NewTLV(t, value)
case []byte:
m[t] = NewTLV(t, []byte(v.([]byte)))
case Body:
m[t] = v.(Body)
default:
return fmt.Errorf("unsupported Tag-Length-Value field data: %#v", v)
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。