本文整理匯總了Golang中github.com/myshkin5/jsonstruct.JSONStruct.IntWithDefault方法的典型用法代碼示例。如果您正苦於以下問題:Golang JSONStruct.IntWithDefault方法的具體用法?Golang JSONStruct.IntWithDefault怎麽用?Golang JSONStruct.IntWithDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/myshkin5/jsonstruct.JSONStruct
的用法示例。
在下文中一共展示了JSONStruct.IntWithDefault方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func (r *Reader) Init(config jsonstruct.JSONStruct) error {
port := config.IntWithDefault(Port, DefaultPort)
remoteAddr := config.StringWithDefault(RemoteWriterAddr, DefaultRemoteWriterAddr)
resp, err := http.DefaultClient.Get(fmt.Sprintf("http://%s:%d/", remoteAddr, port))
if err != nil {
return err
}
r.sseReader = vitosse.NewReadCloser(resp.Body)
return nil
}
示例2: Init
func (w *Writer) Init(config jsonstruct.JSONStruct) error {
port := config.IntWithDefault(Port, DefaultPort)
remoteAddr := config.StringWithDefault(RemoteReaderAddr, DefaultRemoteReaderAddr)
raddr, err := net.ResolveUDPAddr("udp4", net.JoinHostPort(remoteAddr, strconv.Itoa(port)))
if err != nil {
return err
}
w.connection, err = net.DialUDP("udp4", nil, raddr)
if err != nil {
return err
}
return nil
}
示例3: Init
func (s *Scheme) Init(config jsonstruct.JSONStruct) error {
s.messagesPerSecond = config.IntWithDefault(MessagesPerSecond, DefaultMessagesPerSecond)
expectedMessagesPerSecond := config.IntWithDefault(ExpectedMessagesPerSecond, DefaultExpectedMessagesPerSecond)
s.bytesPerMessage = config.IntWithDefault(BytesPerMessage, DefaultBytesPerMessage)
var err error
s.reportCycle, err = config.DurationWithDefault(ReportCycle, DefaultReportCycle)
if err != nil {
return err
}
if expectedMessagesPerSecond == 0 {
expectedMessagesPerSecond = s.messagesPerSecond
}
s.buffer = make([]byte, s.bytesPerMessage)
if s.messagesPerSecond > 0 {
s.tickerTime = time.Second / time.Duration(s.messagesPerSecond)
}
s.done.Add(1)
if s.reporter == nil {
s.reporter = &ReporterImpl{}
}
s.reporter.Init(expectedMessagesPerSecond, s.reportCycle)
return nil
}