parent
74498c8fcd
commit
f145e6e74e
8
Makefile
8
Makefile
|
@ -2,7 +2,7 @@ VERSION = $(shell git describe --tags)
|
||||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
|
|
||||||
run: clean build
|
run: clean build
|
||||||
./autogenpb
|
make -C testSort/
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@GO111MODULE=off go vet
|
@GO111MODULE=off go vet
|
||||||
|
@ -18,8 +18,7 @@ install:
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
# // to globally reset paths:
|
make -C testSort/ goimports
|
||||||
# // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
|
|
||||||
|
|
||||||
redomod:
|
redomod:
|
||||||
rm -f go.*
|
rm -f go.*
|
||||||
|
@ -31,5 +30,4 @@ reset:
|
||||||
reset
|
reset
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm test.sort.pb.go
|
-rm test.sort.pb.go autogenpb
|
||||||
-rm autogenpb
|
|
||||||
|
|
30
main.go
30
main.go
|
@ -8,12 +8,13 @@ import (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
f, _ := os.OpenFile("test.sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
|
f, _ := os.OpenFile("test.sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
|
||||||
header(f, "autogenpb")
|
header(f, "main")
|
||||||
syncLock(f, "godeplock")
|
syncLock(f, "godeplock")
|
||||||
|
iterTop(f, "GoDep")
|
||||||
}
|
}
|
||||||
|
|
||||||
func header(w io.Writer, name string) {
|
func header(w io.Writer, name string) {
|
||||||
fmt.Fprintln(w, "package " + name)
|
fmt.Fprintln(w, "package "+name)
|
||||||
fmt.Fprintln(w, "")
|
fmt.Fprintln(w, "")
|
||||||
fmt.Fprintln(w, "// this is becoming a standard format")
|
fmt.Fprintln(w, "// this is becoming a standard format")
|
||||||
fmt.Fprintln(w, "// todo: autogenerate this from the .proto file?")
|
fmt.Fprintln(w, "// todo: autogenerate this from the .proto file?")
|
||||||
|
@ -29,6 +30,29 @@ func header(w io.Writer, name string) {
|
||||||
|
|
||||||
func syncLock(w io.Writer, name string) {
|
func syncLock(w io.Writer, name string) {
|
||||||
fmt.Fprintln(w, "// bad global lock until I figure out some other plan")
|
fmt.Fprintln(w, "// bad global lock until I figure out some other plan")
|
||||||
fmt.Fprintln(w, "var " + name + " sync.RWMutex")
|
fmt.Fprintln(w, "var "+name+" sync.RWMutex")
|
||||||
fmt.Fprintln(w, "")
|
fmt.Fprintln(w, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func iterTop(w io.Writer, name string) {
|
||||||
|
fmt.Fprintln(w, "type "+name+"Iterator struct {")
|
||||||
|
fmt.Fprintln(w, " sync.RWMutex")
|
||||||
|
fmt.Fprintln(w, "")
|
||||||
|
fmt.Fprintln(w, " packs []*"+name)
|
||||||
|
fmt.Fprintln(w, " index int")
|
||||||
|
fmt.Fprintln(w, "}")
|
||||||
|
fmt.Fprintln(w, "")
|
||||||
|
fmt.Fprintln(w, "// New"+name+"Iterator initializes a new iterator.")
|
||||||
|
fmt.Fprintln(w, "func New"+name+"Iterator(packs []*"+name+") *"+name+"Iterator {")
|
||||||
|
fmt.Fprintln(w, " return &"+name+"Iterator{packs: packs}")
|
||||||
|
fmt.Fprintln(w, "}")
|
||||||
|
fmt.Fprintln(w, "")
|
||||||
|
fmt.Fprintln(w, "// Scan moves to the next element and returns false if there are no more packs.")
|
||||||
|
fmt.Fprintln(w, "func (it *"+name+"Iterator) Scan() bool {")
|
||||||
|
fmt.Fprintln(w, " if it.index >= len(it.packs) {")
|
||||||
|
fmt.Fprintln(w, " return false")
|
||||||
|
fmt.Fprintln(w, " }")
|
||||||
|
fmt.Fprintln(w, " it.index++")
|
||||||
|
fmt.Fprintln(w, " return true")
|
||||||
|
fmt.Fprintln(w, "}")
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,172 @@
|
||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.35.2-devel
|
||||||
|
// protoc v3.21.12
|
||||||
|
// source: test.proto
|
||||||
|
|
||||||
|
// store go dependancies
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
type GoDep struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` // md5sum/hash value from the go.sum file
|
||||||
|
Ctime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=ctime,proto3" json:"ctime,omitempty"` // get the go date from 'go list' ?
|
||||||
|
Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` // v1.2.2
|
||||||
|
GoPath string `protobuf:"bytes,4,opt,name=goPath,proto3" json:"goPath,omitempty"` // "go.wit.com/lib/foo"
|
||||||
|
GoVersion string `protobuf:"bytes,5,opt,name=goVersion,proto3" json:"goVersion,omitempty"` // version of golang the developer used to make this package version
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GoDep) Reset() {
|
||||||
|
*x = GoDep{}
|
||||||
|
mi := &file_test_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GoDep) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GoDep) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GoDep) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_test_proto_msgTypes[0]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use GoDep.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GoDep) Descriptor() ([]byte, []int) {
|
||||||
|
return file_test_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GoDep) GetHash() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Hash
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GoDep) GetCtime() *timestamppb.Timestamp {
|
||||||
|
if x != nil {
|
||||||
|
return x.Ctime
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GoDep) GetVersion() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Version
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GoDep) GetGoPath() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.GoPath
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GoDep) GetGoVersion() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.GoVersion
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
var File_test_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_test_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61,
|
||||||
|
0x69, 0x6e, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72,
|
||||||
|
0x6f, 0x74, 0x6f, 0x22, 0x9d, 0x01, 0x0a, 0x05, 0x47, 0x6f, 0x44, 0x65, 0x70, 0x12, 0x12, 0x0a,
|
||||||
|
0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73,
|
||||||
|
0x68, 0x12, 0x30, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
||||||
|
0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||||
|
0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x63, 0x74,
|
||||||
|
0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a,
|
||||||
|
0x06, 0x67, 0x6f, 0x50, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67,
|
||||||
|
0x6f, 0x50, 0x61, 0x74, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69,
|
||||||
|
0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x56, 0x65, 0x72, 0x73,
|
||||||
|
0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_test_proto_rawDescOnce sync.Once
|
||||||
|
file_test_proto_rawDescData = file_test_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_test_proto_rawDescGZIP() []byte {
|
||||||
|
file_test_proto_rawDescOnce.Do(func() {
|
||||||
|
file_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_test_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
|
var file_test_proto_goTypes = []any{
|
||||||
|
(*GoDep)(nil), // 0: main.GoDep
|
||||||
|
(*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp
|
||||||
|
}
|
||||||
|
var file_test_proto_depIdxs = []int32{
|
||||||
|
1, // 0: main.GoDep.ctime:type_name -> google.protobuf.Timestamp
|
||||||
|
1, // [1:1] is the sub-list for method output_type
|
||||||
|
1, // [1:1] is the sub-list for method input_type
|
||||||
|
1, // [1:1] is the sub-list for extension type_name
|
||||||
|
1, // [1:1] is the sub-list for extension extendee
|
||||||
|
0, // [0:1] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_test_proto_init() }
|
||||||
|
func file_test_proto_init() {
|
||||||
|
if File_test_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: file_test_proto_rawDesc,
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 1,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_test_proto_goTypes,
|
||||||
|
DependencyIndexes: file_test_proto_depIdxs,
|
||||||
|
MessageInfos: file_test_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_test_proto = out.File
|
||||||
|
file_test_proto_rawDesc = nil
|
||||||
|
file_test_proto_goTypes = nil
|
||||||
|
file_test_proto_depIdxs = nil
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
VERSION = $(shell git describe --tags)
|
||||||
|
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
|
|
||||||
|
run: clean test.pb.go build
|
||||||
|
./testSort
|
||||||
|
|
||||||
|
vet:
|
||||||
|
@GO111MODULE=off go vet
|
||||||
|
@echo this go library package builds okay
|
||||||
|
|
||||||
|
build:
|
||||||
|
GO111MODULE=off go build \
|
||||||
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
|
install:
|
||||||
|
GO111MODULE=off go install \
|
||||||
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
|
goimports:
|
||||||
|
goimports -w *.go
|
||||||
|
# // to globally reset paths:
|
||||||
|
# // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
|
||||||
|
|
||||||
|
redomod:
|
||||||
|
rm -f go.*
|
||||||
|
GO111MODULE= go mod init
|
||||||
|
GO111MODULE= go mod tidy
|
||||||
|
|
||||||
|
reset:
|
||||||
|
# clear your terminal
|
||||||
|
reset
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm *.pb.go testSort
|
|
@ -0,0 +1,7 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "log"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.Println("hello testSort")
|
||||||
|
}
|
Loading…
Reference in New Issue