Documentation
¶
Index ¶
- Variables
- func GetFilename(pb proto.Message) (string, error)
- func GetString(pb proto.Message, varname string) (string, error)
- func IdentifyPB(filename string) (string, string, error)
- func SetFilename(pb proto.Message, filename string) (bool, error)
- func VersionCheck(pb proto.Message) (string, string, error)
- func VersionCheckFile(pb proto.Message, filename string) (string, string, error)
- type FakeFile
- func (*FakeFile) Descriptor() ([]byte, []int)deprecated
- func (x *FakeFile) GetUuid() string
- func (x *FakeFile) GetVersion() string
- func (*FakeFile) ProtoMessage()
- func (x *FakeFile) ProtoReflect() protoreflect.Message
- func (x *FakeFile) Reset()
- func (x *FakeFile) String() string
- func (v *FakeFile) Unmarshal(data []byte) error
- type Filetype
- type FiletypeScanner
- type Filetypes
- func (x *Filetypes) All() *FiletypeScanner
- func (x *Filetypes) Append(y *Filetype)
- func (x *Filetypes) Clone(y *Filetype) *Filetype
- func (x *Filetypes) Delete(y *Filetype) bool
- func (*Filetypes) Descriptor() ([]byte, []int)deprecated
- func (v *Filetypes) FormatJSON() string
- func (v *Filetypes) FormatTEXT() string
- func (x *Filetypes) GetFiletypes() []*Filetype
- func (x *Filetypes) GetUuid() string
- func (x *Filetypes) GetVersion() string
- func (x *Filetypes) IterAll() iter.Seq[*Filetype]
- func (x *Filetypes) Len() int
- func (v *Filetypes) Marshal() ([]byte, error)
- func (v *Filetypes) MarshalJSON() ([]byte, error)
- func (*Filetypes) ProtoMessage()
- func (x *Filetypes) ProtoReflect() protoreflect.Message
- func (x *Filetypes) Reset()
- func (x *Filetypes) String() string
- func (v *Filetypes) Unmarshal(data []byte) error
- func (v *Filetypes) UnmarshalJSON(data []byte) error
- func (v *Filetypes) UnmarshalTEXT(data []byte) error
- type FiletypesScanner
- type Identify
- func (*Identify) Descriptor() ([]byte, []int)deprecated
- func (v *Identify) FormatJSON() string
- func (v *Identify) FormatTEXT() string
- func (x *Identify) GetUuid() string
- func (x *Identify) GetVersion() string
- func (v *Identify) Marshal() ([]byte, error)
- func (v *Identify) MarshalJSON() ([]byte, error)
- func (*Identify) ProtoMessage()
- func (x *Identify) ProtoReflect() protoreflect.Message
- func (x *Identify) Reset()
- func (x *Identify) String() string
- func (v *Identify) Unmarshal(data []byte) error
- func (v *Identify) UnmarshalJSON(data []byte) error
- func (v *Identify) UnmarshalTEXT(data []byte) error
- type IdentifyScanner
- type PatchError
Constants ¶
This section is empty.
Variables ¶
var ErrEmpty error = fmt.Errorf("config file was empty")
var ErrMarshal error = fmt.Errorf("protobuf parse error")
var ErrProtoNoVarName error = errors.New("name not in .proto")
var ErrProtoVarNotString error = errors.New("name exists but is not a string")
var File_fakefile_proto protoreflect.FileDescriptor
var File_filetype_proto protoreflect.FileDescriptor
Functions ¶
func GetFilename ¶ added in v0.0.8
this will try both "filename" and "Filename"
func IdentifyPB ¶
print the protobuf in human form
func SetFilename ¶ added in v0.0.8
sets "Filename" if it exists in the protobuf
func VersionCheck ¶ added in v0.0.11
verify 'version' for .pb files application should die if they don't match returns (newVersion, oldVersion, error)
Types ¶
type FakeFile ¶ added in v0.0.8
type FakeFile struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:uuid:`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:`
// contains filtered or unexported fields
}
func (*FakeFile) Descriptor
deprecated
added in
v0.0.8
func (*FakeFile) GetVersion ¶ added in v0.0.8
func (*FakeFile) ProtoMessage ¶ added in v0.0.8
func (*FakeFile) ProtoMessage()
func (*FakeFile) ProtoReflect ¶ added in v0.0.8
func (x *FakeFile) ProtoReflect() protoreflect.Message
type Filetype ¶
type Filetype struct {
Nothing bool `protobuf:"varint,1,opt,name=nothing,proto3" json:"nothing,omitempty"` // generate autosave functions (in marshal.go ?)
// contains filtered or unexported fields
}
func (*Filetype) Descriptor
deprecated
func (*Filetype) GetNothing ¶
func (*Filetype) ProtoMessage ¶
func (*Filetype) ProtoMessage()
func (*Filetype) ProtoReflect ¶
func (x *Filetype) ProtoReflect() protoreflect.Message
type FiletypeScanner ¶
func (*FiletypeScanner) Next ¶
func (it *FiletypeScanner) Next() *Filetype
Next() returns the next thing in the array
func (*FiletypeScanner) Scan ¶
func (it *FiletypeScanner) Scan() bool
type Filetypes ¶
type Filetypes struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` // `autogenpb:uuid:c1239110-ad4f-41f3-b0f5-189034f0a3a7`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v0.0.1`
Filetypes []*Filetype `protobuf:"bytes,3,rep,name=Filetypes,proto3" json:"Filetypes,omitempty"` // an array of each .proto file in the working directory
// contains filtered or unexported fields
}
I know, I know, the whole point of using protobuf is so you don't need a uuid or versions because it's inherently forward compatable. nonetheless, a simple stubbed out trivial and empty protobuf message can marshal and identify all the files also, this could be used to modify /usr/bin/file /usr/share/magic to identify the files maybe this is already been done and is pointless, but it seems like a good idea
func NewFiletypes ¶
func NewFiletypes() *Filetypes
func (*Filetypes) All ¶
func (x *Filetypes) All() *FiletypeScanner
func (*Filetypes) Append ¶
a Append() shortcut (that does Clone() with a mutex) notsure if it really works doesn't allow nil
func (*Filetypes) Clone ¶ added in v0.0.5
a Clone() shortcut (with a mutex). notsure if it really works
func (*Filetypes) Descriptor
deprecated
func (*Filetypes) FormatTEXT ¶
apparently this isn't stable, but it's awesomely better https://protobuf.dev/reference/go/faq/#unstable-text it's brilliant for config files!
func (*Filetypes) GetFiletypes ¶
func (*Filetypes) GetVersion ¶
func (*Filetypes) ProtoMessage ¶
func (*Filetypes) ProtoMessage()
func (*Filetypes) ProtoReflect ¶
func (x *Filetypes) ProtoReflect() protoreflect.Message
func (*Filetypes) UnmarshalJSON ¶
unmarshal json
func (*Filetypes) UnmarshalTEXT ¶
unmarshalTEXT. This reads the .text config file back in after the user edits it
type FiletypesScanner ¶
func (*FiletypesScanner) Next ¶
func (it *FiletypesScanner) Next() *Filetypes
Next() returns the next thing in the array
func (*FiletypesScanner) Scan ¶
func (it *FiletypesScanner) Scan() bool
type Identify ¶
type Identify struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` //
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` //
// contains filtered or unexported fields
}
func (*Identify) Descriptor
deprecated
func (*Identify) FormatTEXT ¶
apparently this isn't stable, but it's awesomely better https://protobuf.dev/reference/go/faq/#unstable-text it's brilliant for config files!
func (*Identify) GetVersion ¶
func (*Identify) ProtoMessage ¶
func (*Identify) ProtoMessage()
func (*Identify) ProtoReflect ¶
func (x *Identify) ProtoReflect() protoreflect.Message
func (*Identify) UnmarshalTEXT ¶
unmarshalTEXT. This reads the .text config file back in after the user edits it
type IdentifyScanner ¶
func (*IdentifyScanner) Next ¶
func (it *IdentifyScanner) Next() *Identify
Next() returns the next thing in the array
func (*IdentifyScanner) Scan ¶
func (it *IdentifyScanner) Scan() bool
type PatchError ¶ added in v0.0.8
type PatchError struct {
// Note: The `XXX_` fields are part of the older struct tags,
// but the reflection logic comes from the modern API.
// In a real generated file, you wouldn't see these tags.
UserName string `protobuf:"bytes,1,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"`
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
LastLogin *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=last_login,json=lastLogin,proto3" json:"last_login,omitempty"`
}
--- Mock of a generated user.pb.go file ---
func (*PatchError) ProtoMessage ¶ added in v0.0.8
func (*PatchError) ProtoMessage()
func (*PatchError) ProtoReflect ¶ added in v0.0.8
func (x *PatchError) ProtoReflect() protoreflect.Message
In a real generated file, ProtoReflect() would be fully implemented. For this example, we don't need it as the marshallers will use reflection.
func (*PatchError) Reset ¶ added in v0.0.8
func (x *PatchError) Reset()
func (*PatchError) String ¶ added in v0.0.8
func (x *PatchError) String() string