Skip to content

Instantly share code, notes, and snippets.

View syossan27's full-sized avatar
💭
🤔

syossan27 syossan27

💭
🤔
View GitHub Profile
func main() {
f, err := os.Open("hoge.txt")
if err != nil {
println("Err")
}
ret, err := f.Seek(0, 1) //ファイルオフセットの現在位置を取得
if err != nil {
println("Err")
}
println(ret)
func main() {
f, err := os.Open("hoge.txt")
if err != nil {
println("Err")
}
// 1回目
err = file_scan(f)
if err != nil {
println("Err")
}
func main() {
f, err := os.Open("hoge.txt")
if err != nil {
println("Err")
}
libraryFunc(f)
scanner := bufio.NewScanner(f)
for scanner.Scan() {
func deriveEqual(this, that *MyStruct) bool {
return (this == nil && that == nil) ||
this != nil && that != nil &&
this.Int64 == that.Int64 &&
((this.StringPtr == nil && that.StringPtr == nil) ||
(this.StringPtr != nil && that.StringPtr != nil && *(this.StringPtr) == *(that.StringPtr)))
}
package main
type MyStruct struct {
Int64 int64
StringPtr *string
}
func (this *MyStruct) Equal(that *MyStruct) bool {
return deriveEqual(this, that)
}
# -*- encoding: utf-8 -*-
Gem::Specification.new do |gem|
gem.authors = ["Hidemasa Togashi", "Masahiro Nakagawa"]
gem.email = ["togachiro@gmail.com", "repeatedly@gmail.com"]
gem.description = %q{Fluentd plugin for Apache Kafka > 0.8}
gem.summary = %q{Fluentd plugin for Apache Kafka > 0.8}
gem.homepage = "https://github.com/fluent/fluent-plugin-kafka"
gem.files = `git ls-files`.split($\)
WARN Unexpected state transition from RUNNING to NOT_RUNNING (org.apache.kafka.streams.processor.internals.StreamThread)
Exception in thread "StreamThread-1" org.apache.kafka.streams.errors.StreamsException: Input record ConsumerRecord(topic = hoge, partition = 0, offset = 0, CreateTime = -1, checksum = 4178856401, serialized key size = -1, serialized value size = 520, key = null,
value = {"level":"info","ts":1503563975.9925625,"caller":"","msg":"tracking.request","RequestData":[{"Request":{"Host":"","Method":"POST","Proto":"HTTP/1.1","Referer":"","RemoteAddr":"","RequestURI":"/","UA":"curl/7.51.0","URL":"/"}},{"Header":[{"Content-Type":["application/json"]},{"Content-Length":["25"]},{"User-Agent":["curl/7.51.0"]},{"Accept":["application/json"]}]},{"Body":"{}"},{"Form":[]},{"PostForm":[]},{"Cookie":[]}]})
has invalid (negative) timestamp. Possibly because a pre-0.10 producer client was used to write this record to Kafka without embedding a timestamp, or because the input topic was created before upgrading the
func DoSomethingVerbosely(foo *Foo, verbosity int) {
// Could combine the next two lines,
// with some loss of readability.
prev := foo.Option(pkg.Verbosity(verbosity))
defer foo.Option(prev)
// ... do some stuff with foo under high verbosity.
}
prevVerbosity := foo.Option(pkg.Verbosity(3))
foo.DoSomeDebugging()
foo.Option(prevVerbosity)
// Verbosity sets Foo's verbosity level to v.
func Verbosity(v int) option {
return func(f *Foo) option {
previous := f.verbosity
f.verbosity = v
return Verbosity(previous)
}
}