Apply .gitignore rules
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package kafkaMgr
|
||||
|
||||
import "strings"
|
||||
|
||||
// Kafka配置对象
|
||||
type KafkaConfig struct {
|
||||
// Brokers的地址
|
||||
Brokers string
|
||||
|
||||
// 主题
|
||||
Topics string
|
||||
|
||||
// 分区
|
||||
Partitions string
|
||||
|
||||
// 分组Id
|
||||
GroupId string
|
||||
|
||||
// 用户名
|
||||
UserName string
|
||||
|
||||
// 密码
|
||||
Passward string
|
||||
|
||||
// 需要的证书文件
|
||||
CertFile string
|
||||
}
|
||||
|
||||
func (this *KafkaConfig) GetBrokerList() []string {
|
||||
if len(this.Brokers) <= 0 {
|
||||
return make([]string, 0)
|
||||
}
|
||||
|
||||
return strings.Split(this.Brokers, ",")
|
||||
}
|
||||
|
||||
func (this *KafkaConfig) GetTopicList() []string {
|
||||
if len(this.Topics) <= 0 {
|
||||
return make([]string, 0)
|
||||
}
|
||||
|
||||
return strings.Split(this.Topics, ",")
|
||||
}
|
||||
|
||||
func (this *KafkaConfig) GetPartitionList() []string {
|
||||
if len(this.Partitions) <= 0 {
|
||||
return make([]string, 0)
|
||||
}
|
||||
|
||||
return strings.Split(this.Partitions, ",")
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package xmlUtil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// 从文件加载
|
||||
// filePath:文件路径
|
||||
// 返回值:
|
||||
// *Node:根节点对象
|
||||
// error:错误信息
|
||||
func LoadFromFile(filePath string) (*Node, error) {
|
||||
data, errMsg := ioutil.ReadFile(filePath)
|
||||
if errMsg != nil {
|
||||
return nil, errMsg
|
||||
}
|
||||
|
||||
return LoadFromByte(data)
|
||||
}
|
||||
|
||||
// 从字节数组加载
|
||||
// data:文档数据
|
||||
// 返回值:
|
||||
// *Node:根节点对象
|
||||
// error:错误信息
|
||||
func LoadFromByte(data []byte) (*Node, error) {
|
||||
return LoadFromString(string(data))
|
||||
}
|
||||
|
||||
// 文档字符串
|
||||
// doc:文档字符串
|
||||
// 返回值:
|
||||
// *Node:根节点对象
|
||||
// error:错误信息
|
||||
func LoadFromString(doc string) (*Node, error) {
|
||||
// xml.Decoder doesn't properly handle whitespace in some doc
|
||||
// see songTextString.xml test case ...
|
||||
reg, _ := regexp.Compile("[ \t\n\r]*<")
|
||||
doc = reg.ReplaceAllString(doc, "<")
|
||||
|
||||
b := bytes.NewBufferString(doc)
|
||||
|
||||
return LoadFromReader(b)
|
||||
}
|
||||
Reference in New Issue
Block a user