From 095e65c80004fd6c60273a007c9974c2f86402a0 Mon Sep 17 00:00:00 2001 From: RSWilli Date: Sat, 2 Sep 2023 00:04:14 +0200 Subject: [PATCH] some staticcheck fixes --- examples/custom_events/main.go | 6 ++++- examples/decodebin/main.go | 2 +- examples/launch/main.go | 2 +- examples/pad-probes/main.go | 4 +++ examples/playbin/main.go | 4 +-- examples/plugins/gofilesink/filesink.go | 30 ++++++++++----------- examples/plugins/gofilesrc/filesrc.go | 36 ++++++++++++------------- examples/toc/main.go | 3 +-- gst/app/gst_app_sink.go | 2 +- gst/c_util.go | 5 ++-- gst/gst_bin.go | 12 ++++----- gst/gst_buffer.go | 3 +-- gst/gst_device.go | 2 +- gst/gst_element.go | 8 +++--- gst/gst_mapinfo.go | 2 +- gst/gst_pad.go | 2 +- gst/gst_pipeline.go | 4 +-- gst/gst_registry.go | 4 +-- gst/gst_stream_collection.go | 2 +- gst/gst_structure.go | 4 +-- 20 files changed, 70 insertions(+), 67 deletions(-) diff --git a/examples/custom_events/main.go b/examples/custom_events/main.go index 39f285b..1445127 100644 --- a/examples/custom_events/main.go +++ b/examples/custom_events/main.go @@ -26,12 +26,16 @@ func createPipeline() (*gst.Pipeline, error) { "audiotestsrc name=src ! queue max-size-time=2000000000 ! fakesink name=sink sync=true", ) + if err != nil { + return nil, err + } + // Retrieve the sink element sinks, err := pipeline.GetSinkElements() if err != nil { return nil, err } else if len(sinks) != 1 { - return nil, errors.New("Expected one sink back") + return nil, errors.New("expected one sink back") } sink := sinks[0] diff --git a/examples/decodebin/main.go b/examples/decodebin/main.go index 890ba7f..7319211 100644 --- a/examples/decodebin/main.go +++ b/examples/decodebin/main.go @@ -90,7 +90,7 @@ func buildPipeline() (*gst.Pipeline, error) { fmt.Printf("New pad added, is_audio=%v, is_video=%v\n", isAudio, isVideo) if !isAudio && !isVideo { - err := errors.New("Could not detect media stream type") + err := errors.New("could not detect media stream type") // We can send errors directly to the pipeline bus if they occur. // These will be handled downstream. msg := gst.NewErrorMessage(self, gst.NewGError(1, err), fmt.Sprintf("Received caps: %s", caps.String()), nil) diff --git a/examples/launch/main.go b/examples/launch/main.go index e1772e5..1a2984b 100644 --- a/examples/launch/main.go +++ b/examples/launch/main.go @@ -16,7 +16,7 @@ import ( func runPipeline(mainLoop *glib.MainLoop) error { if len(os.Args) == 1 { - return errors.New("Pipeline string cannot be empty") + return errors.New("pipeline string cannot be empty") } gst.Init(&os.Args) diff --git a/examples/pad-probes/main.go b/examples/pad-probes/main.go index 9c02556..10ff891 100644 --- a/examples/pad-probes/main.go +++ b/examples/pad-probes/main.go @@ -29,6 +29,10 @@ func padProbes(mainLoop *glib.MainLoop) error { "audiotestsrc name=src ! audio/x-raw,format=S16LE,channels=1 ! fakesink", ) + if err != nil { + return err + } + // Get the audiotestsrc element from the pipeline that GStreamer // created for us while parsing the launch syntax above. // diff --git a/examples/playbin/main.go b/examples/playbin/main.go index 0294f36..231b2f8 100644 --- a/examples/playbin/main.go +++ b/examples/playbin/main.go @@ -21,11 +21,9 @@ import ( "github.com/go-gst/go-gst/gst" ) -var srcURI string - func playbin(mainLoop *glib.MainLoop) error { if len(os.Args) < 2 { - return errors.New("Usage: playbin ") + return errors.New("usage: playbin ") } gst.Init(nil) diff --git a/examples/plugins/gofilesink/filesink.go b/examples/plugins/gofilesink/filesink.go index 2f16cb1..8e6a783 100644 --- a/examples/plugins/gofilesink/filesink.go +++ b/examples/plugins/gofilesink/filesink.go @@ -88,7 +88,7 @@ type settings struct { // Finally a structure is defined that implements (at a minimum) the glib.GoObject interface. // It is possible to signal to the bindings to inherit from other classes or implement other // interfaces via the registration and TypeInit processes. -type fileSink struct { +type FileSink struct { // The settings for the element settings *settings // The current state of the element @@ -97,9 +97,9 @@ type fileSink struct { // setLocation is a simple method to check the validity of a provided file path and set the // local value with it. -func (f *fileSink) setLocation(path string) error { +func (f *FileSink) setLocation(path string) error { if f.state.started { - return errors.New("Changing the `location` property on a started `GoFileSink` is not supported") + return errors.New("changing the `location` property on a started `GoFileSink` is not supported") } f.settings.location = strings.TrimPrefix(path, "file://") // should obviously use url.URL and do actual parsing return nil @@ -111,9 +111,9 @@ func (f *fileSink) setLocation(path string) error { // Every element needs to provide its own constructor that returns an initialized glib.GoObjectSubclass // implementation. Here we simply create a new fileSink with zeroed settings and state objects. -func (f *fileSink) New() glib.GoObjectSubclass { +func (f *FileSink) New() glib.GoObjectSubclass { CAT.Log(gst.LevelLog, "Initializing new fileSink object") - return &fileSink{ + return &FileSink{ settings: &settings{}, state: &state{}, } @@ -121,7 +121,7 @@ func (f *fileSink) New() glib.GoObjectSubclass { // The ClassInit method should specify the metadata for this element and add any pad templates // and properties. -func (f *fileSink) ClassInit(klass *glib.ObjectClass) { +func (f *FileSink) ClassInit(klass *glib.ObjectClass) { CAT.Log(gst.LevelLog, "Initializing gofilesink class") class := gst.ToElementClass(klass) class.SetMetadata( @@ -150,7 +150,7 @@ func (f *fileSink) ClassInit(klass *glib.ObjectClass) { // SetProperty is called when a `value` is set to the property at index `id` in the // properties slice that we installed during ClassInit. It should attempt to register // the value locally or signal any errors that occur in the process. -func (f *fileSink) SetProperty(self *glib.Object, id uint, value *glib.Value) { +func (f *FileSink) SetProperty(self *glib.Object, id uint, value *glib.Value) { param := properties[id] switch param.Name() { case "location": @@ -173,7 +173,7 @@ func (f *fileSink) SetProperty(self *glib.Object, id uint, value *glib.Value) { // GetProperty is called to retrieve the value of the property at index `id` in the properties // slice provided at ClassInit. -func (f *fileSink) GetProperty(self *glib.Object, id uint) *glib.Value { +func (f *FileSink) GetProperty(self *glib.Object, id uint) *glib.Value { param := properties[id] switch param.Name() { case "location": @@ -196,7 +196,7 @@ func (f *fileSink) GetProperty(self *glib.Object, id uint) *glib.Value { // If the method is not overridden by the implementing struct, it will be inherited from the parent class. // Start is called to start the filesink. Open the file for writing and set the internal state. -func (f *fileSink) Start(self *base.GstBaseSink) bool { +func (f *FileSink) Start(self *base.GstBaseSink) bool { if f.state.started { self.ErrorMessage(gst.DomainResource, gst.ResourceErrorSettings, "GoFileSink is already started", "") return false @@ -225,7 +225,7 @@ func (f *fileSink) Start(self *base.GstBaseSink) bool { } // Stop is called to stop the element. Set the internal state and close the file. -func (f *fileSink) Stop(self *base.GstBaseSink) bool { +func (f *FileSink) Stop(self *base.GstBaseSink) bool { if !f.state.started { self.ErrorMessage(gst.DomainResource, gst.ResourceErrorSettings, "GoFileSink is not started", "") return false @@ -241,7 +241,7 @@ func (f *fileSink) Stop(self *base.GstBaseSink) bool { } // Render is called when a buffer is ready to be written to the file. -func (f *fileSink) Render(self *base.GstBaseSink, buffer *gst.Buffer) gst.FlowReturn { +func (f *FileSink) Render(self *base.GstBaseSink, buffer *gst.Buffer) gst.FlowReturn { if !f.state.started { self.ErrorMessage(gst.DomainResource, gst.ResourceErrorSettings, "GoFileSink is not started", "") return gst.FlowError @@ -263,16 +263,16 @@ func (f *fileSink) Render(self *base.GstBaseSink, buffer *gst.Buffer) gst.FlowRe // URIHandler implementations are the methods required by the GstURIHandler interface. // GetURI returns the currently configured URI -func (f *fileSink) GetURI() string { return fmt.Sprintf("file://%s", f.settings.location) } +func (f *FileSink) GetURI() string { return fmt.Sprintf("file://%s", f.settings.location) } // GetURIType returns the types of URI this element supports. -func (f *fileSink) GetURIType() gst.URIType { return gst.URISource } +func (f *FileSink) GetURIType() gst.URIType { return gst.URISource } // GetProtocols returns the protcols this element supports. -func (f *fileSink) GetProtocols() []string { return []string{"file"} } +func (f *FileSink) GetProtocols() []string { return []string{"file"} } // SetURI should set the URI that this element is working on. -func (f *fileSink) SetURI(uri string) (bool, error) { +func (f *FileSink) SetURI(uri string) (bool, error) { if uri == "file://" { return true, nil } diff --git a/examples/plugins/gofilesrc/filesrc.go b/examples/plugins/gofilesrc/filesrc.go index d3a7a65..d89dbb5 100644 --- a/examples/plugins/gofilesrc/filesrc.go +++ b/examples/plugins/gofilesrc/filesrc.go @@ -90,7 +90,7 @@ type settings struct { // Finally a structure is defined that implements (at a minimum) the gst.GoElement interface. // It is possible to signal to the bindings to inherit from other classes or implement other // interfaces via the registration and TypeInit processes. -type fileSrc struct { +type FileSrc struct { // The settings for the element settings *settings // The current state of the element @@ -101,9 +101,9 @@ type fileSrc struct { // setLocation is a simple method to check the validity of a provided file path and set the // local value with it. -func (f *fileSrc) setLocation(path string) error { +func (f *FileSrc) setLocation(path string) error { if f.state.started { - return errors.New("Changing the `location` property on a started `GoFileSrc` is not supported") + return errors.New("changing the `location` property on a started `GoFileSrc` is not supported") } f.settings.location = strings.TrimPrefix(path, "file://") // should obviously use url.URL and do actual parsing return nil @@ -115,9 +115,9 @@ func (f *fileSrc) setLocation(path string) error { // Every element needs to provide its own constructor that returns an initialized // glib.GoObjectSubclass and state objects. -func (f *fileSrc) New() glib.GoObjectSubclass { +func (f *FileSrc) New() glib.GoObjectSubclass { CAT.Log(gst.LevelLog, "Initializing new fileSrc object") - return &fileSrc{ + return &FileSrc{ settings: &settings{}, state: &state{}, } @@ -125,7 +125,7 @@ func (f *fileSrc) New() glib.GoObjectSubclass { // The ClassInit method should specify the metadata for this element and add any pad templates // and properties. -func (f *fileSrc) ClassInit(klass *glib.ObjectClass) { +func (f *FileSrc) ClassInit(klass *glib.ObjectClass) { CAT.Log(gst.LevelLog, "Initializing gofilesrc class") class := gst.ToElementClass(klass) class.SetMetadata( @@ -154,7 +154,7 @@ func (f *fileSrc) ClassInit(klass *glib.ObjectClass) { // SetProperty is called when a `value` is set to the property at index `id` in the // properties slice that we installed during ClassInit. It should attempt to register // the value locally or signal any errors that occur in the process. -func (f *fileSrc) SetProperty(self *glib.Object, id uint, value *glib.Value) { +func (f *FileSrc) SetProperty(self *glib.Object, id uint, value *glib.Value) { param := properties[id] switch param.Name() { case "location": @@ -177,7 +177,7 @@ func (f *fileSrc) SetProperty(self *glib.Object, id uint, value *glib.Value) { // GetProperty is called to retrieve the value of the property at index `id` in the properties // slice provided at ClassInit. -func (f *fileSrc) GetProperty(self *glib.Object, id uint) *glib.Value { +func (f *FileSrc) GetProperty(self *glib.Object, id uint) *glib.Value { param := properties[id] switch param.Name() { case "location": @@ -199,7 +199,7 @@ func (f *fileSrc) GetProperty(self *glib.Object, id uint) *glib.Value { // Constructed is called when the type system is done constructing the object. Any finalizations required // during the initialization process can be performed here. In this example, we set the format on our // underlying GstBaseSrc to bytes. -func (f *fileSrc) Constructed(self *glib.Object) { +func (f *FileSrc) Constructed(self *glib.Object) { base.ToGstBaseSrc(self).Log(CAT, gst.LevelLog, "Setting format of GstBaseSrc to bytes") base.ToGstBaseSrc(self).SetFormat(gst.FormatBytes) } @@ -208,10 +208,10 @@ func (f *fileSrc) Constructed(self *glib.Object) { // If the method is not overridden by the implementing struct, it will be inherited from the parent class. // IsSeekable returns that we are, in fact, seekable. -func (f *fileSrc) IsSeekable(*base.GstBaseSrc) bool { return true } +func (f *FileSrc) IsSeekable(*base.GstBaseSrc) bool { return true } // GetSize will return the total size of the file at the configured location. -func (f *fileSrc) GetSize(self *base.GstBaseSrc) (bool, int64) { +func (f *FileSrc) GetSize(self *base.GstBaseSrc) (bool, int64) { if !f.state.started { return false, 0 } @@ -220,7 +220,7 @@ func (f *fileSrc) GetSize(self *base.GstBaseSrc) (bool, int64) { // Start is called to start this element. In this example, the configured file is opened for reading, // and any error encountered in the process is posted to the pipeline. -func (f *fileSrc) Start(self *base.GstBaseSrc) bool { +func (f *FileSrc) Start(self *base.GstBaseSrc) bool { if f.state.started { self.ErrorMessage(gst.DomainResource, gst.ResourceErrorSettings, "GoFileSrc is already started", "") return false @@ -268,7 +268,7 @@ func (f *fileSrc) Start(self *base.GstBaseSrc) bool { } // Stop is called to stop the element. The file is closed and the local values are zeroed out. -func (f *fileSrc) Stop(self *base.GstBaseSrc) bool { +func (f *FileSrc) Stop(self *base.GstBaseSrc) bool { if !f.state.started { self.ErrorMessage(gst.DomainResource, gst.ResourceErrorSettings, "FileSrc is not started", "") return false @@ -290,7 +290,7 @@ func (f *fileSrc) Stop(self *base.GstBaseSrc) bool { // Fill is called to fill a pre-allocated buffer with the data at offset up to the given size. // Since we declared that we are seekable, we need to support the provided offset not necessarily matching // where we currently are in the file. This is why we store the position in the file locally. -func (f *fileSrc) Fill(self *base.GstBaseSrc, offset uint64, size uint, buffer *gst.Buffer) gst.FlowReturn { +func (f *FileSrc) Fill(self *base.GstBaseSrc, offset uint64, size uint, buffer *gst.Buffer) gst.FlowReturn { if !f.state.started || f.state.file == nil { self.ErrorMessage(gst.DomainCore, gst.CoreErrorFailed, "Not started yet", "") return gst.FlowError @@ -332,16 +332,16 @@ func (f *fileSrc) Fill(self *base.GstBaseSrc, offset uint64, size uint, buffer * // URIHandler implementations are the methods required by the GstURIHandler interface. // GetURI returns the currently configured URI -func (f *fileSrc) GetURI() string { return fmt.Sprintf("file://%s", f.settings.location) } +func (f *FileSrc) GetURI() string { return fmt.Sprintf("file://%s", f.settings.location) } // GetURIType returns the types of URI this element supports. -func (f *fileSrc) GetURIType() gst.URIType { return gst.URISource } +func (f *FileSrc) GetURIType() gst.URIType { return gst.URISource } // GetProtocols returns the protcols this element supports. -func (f *fileSrc) GetProtocols() []string { return []string{"file"} } +func (f *FileSrc) GetProtocols() []string { return []string{"file"} } // SetURI should set the URI that this element is working on. -func (f *fileSrc) SetURI(uri string) (bool, error) { +func (f *FileSrc) SetURI(uri string) (bool, error) { if uri == "file://" { return true, nil } diff --git a/examples/toc/main.go b/examples/toc/main.go index b4b5fa4..a1c93be 100644 --- a/examples/toc/main.go +++ b/examples/toc/main.go @@ -26,7 +26,7 @@ func tagsetter(mainLoop *glib.MainLoop) error { gst.Init(nil) if len(os.Args) < 2 { - return errors.New("Usage: toc ") + return errors.New("usage: toc ") } pipeline, err := gst.NewPipeline("") @@ -99,7 +99,6 @@ func tagsetter(mainLoop *glib.MainLoop) error { // End of stream case gst.MessageEOS: msg.Unref() - break // Errors from any elements case gst.MessageError: diff --git a/gst/app/gst_app_sink.go b/gst/app/gst_app_sink.go index 5329846..baee8c2 100644 --- a/gst/app/gst_app_sink.go +++ b/gst/app/gst_app_sink.go @@ -35,7 +35,7 @@ type SinkCallbacks struct { } // ErrEOS represents that the stream has ended. -var ErrEOS = errors.New("Pipeline has reached end-of-stream") +var ErrEOS = errors.New("pipeline has reached end-of-stream") // Sink wraps an Element made with the appsink plugin with additional methods for pulling samples. type Sink struct{ *base.GstBaseSink } diff --git a/gst/c_util.go b/gst/c_util.go index 084a836..5b3810b 100644 --- a/gst/c_util.go +++ b/gst/c_util.go @@ -31,9 +31,8 @@ func gboolean(b bool) C.gboolean { // gdateToTime converts a GDate to a time object. func gdateToTime(gdate *C.GDate) time.Time { - tm := time.Time{} - tm.AddDate(int(C.g_date_get_year(gdate)), int(C.g_date_get_month(gdate)), int(C.g_date_get_day(gdate))) - return tm + // should this really be local time? + return time.Date(int(C.g_date_get_year(gdate)), time.Month(C.g_date_get_month(gdate)), int(C.g_date_get_day(gdate)), 0, 0, 0, 0, time.Local) } // gstDateTimeToTime converts a GstDateTime to a time object. If the datetime object could not be parsed, diff --git a/gst/gst_bin.go b/gst/gst_bin.go index d1457c3..3f5141c 100644 --- a/gst/gst_bin.go +++ b/gst/gst_bin.go @@ -128,7 +128,7 @@ func (b *Bin) GetElementByName(name string) (*Element, error) { defer C.free(unsafe.Pointer(cName)) elem := C.gst_bin_get_by_name((*C.GstBin)(b.Instance()), (*C.gchar)(cName)) if elem == nil { - return nil, fmt.Errorf("Could not find element with name %s", name) + return nil, fmt.Errorf("could not find element with name %s", name) } return wrapElement(glib.TransferFull(unsafe.Pointer(elem))), nil } @@ -140,7 +140,7 @@ func (b *Bin) GetElementByNameRecursive(name string) (*Element, error) { defer C.free(unsafe.Pointer(cName)) elem := C.gst_bin_get_by_name_recurse_up((*C.GstBin)(b.Instance()), (*C.gchar)(cName)) if elem == nil { - return nil, fmt.Errorf("Could not find element with name %s", name) + return nil, fmt.Errorf("could not find element with name %s", name) } return wrapElement(glib.TransferFull(unsafe.Pointer(elem))), nil } @@ -185,7 +185,7 @@ func (b *Bin) GetElementsSorted() ([]*Element, error) { func (b *Bin) GetByInterface(iface glib.Interface) (*Element, error) { elem := C.gst_bin_get_by_interface(b.Instance(), C.GType(iface.Type())) if elem == nil { - return nil, fmt.Errorf("Could not find any elements implementing %s", iface.Type().Name()) + return nil, fmt.Errorf("could not find any elements implementing %s", iface.Type().Name()) } return wrapElement(glib.TransferFull(unsafe.Pointer(elem))), nil } @@ -210,7 +210,7 @@ func (b *Bin) GetAllByInterface(iface glib.Interface) ([]*Element, error) { // Add adds an element to the bin. func (b *Bin) Add(elem *Element) error { if ok := C.gst_bin_add((*C.GstBin)(b.Instance()), (*C.GstElement)(elem.Instance())); !gobool(ok) { - return fmt.Errorf("Failed to add element to pipeline: %s", elem.GetName()) + return fmt.Errorf("failed to add element to pipeline: %s", elem.GetName()) } return nil } @@ -228,7 +228,7 @@ func (b *Bin) AddMany(elems ...*Element) error { // Remove removes an element from the Bin. func (b *Bin) Remove(elem *Element) error { if ok := C.gst_bin_remove((*C.GstBin)(b.Instance()), (*C.GstElement)(elem.Instance())); !gobool(ok) { - return fmt.Errorf("Failed to remove element from pipeline: %s", elem.GetName()) + return fmt.Errorf("failed to remove element from pipeline: %s", elem.GetName()) } return nil } @@ -340,7 +340,7 @@ func iteratorToElementSlice(iterator *C.GstIterator) ([]*Element, error) { elems = append(elems, wrapElement(glib.TransferNone(unsafe.Pointer(cElem)))) C.g_value_unset((*C.GValue)(gval)) default: - return nil, errors.New("Element iterator failed") + return nil, errors.New("element iterator failed") } } } diff --git a/gst/gst_buffer.go b/gst/gst_buffer.go index 351011d..b28b94b 100644 --- a/gst/gst_buffer.go +++ b/gst/gst_buffer.go @@ -22,7 +22,6 @@ import "C" import ( "bytes" "io" - "io/ioutil" "runtime" "unsafe" @@ -104,7 +103,7 @@ func NewBufferFromBytes(b []byte) *Buffer { // NewBufferFromReader returns a new buffer from the given io.Reader. func NewBufferFromReader(rdr io.Reader) (*Buffer, error) { - out, err := ioutil.ReadAll(rdr) + out, err := io.ReadAll(rdr) if err != nil { return nil, err } diff --git a/gst/gst_device.go b/gst/gst_device.go index fc9dc2c..903e85f 100644 --- a/gst/gst_device.go +++ b/gst/gst_device.go @@ -91,7 +91,7 @@ func (d *Device) HasClasses(classes []string) bool { // while in the PLAYING state. func (d *Device) ReconfigureElement(elem *Element) error { if ok := gobool(C.gst_device_reconfigure_element(d.Instance(), elem.Instance())); !ok { - return fmt.Errorf("Failed to reconfigure element %s", elem.GetName()) + return fmt.Errorf("failed to reconfigure element %s", elem.GetName()) } return nil } diff --git a/gst/gst_element.go b/gst/gst_element.go index 07a8d67..a83b299 100644 --- a/gst/gst_element.go +++ b/gst/gst_element.go @@ -365,7 +365,7 @@ func (e *Element) IsURIHandler() bool { // Link wraps gst_element_link and links this element to the given one. func (e *Element) Link(elem *Element) error { if ok := C.gst_element_link((*C.GstElement)(e.Instance()), (*C.GstElement)(elem.Instance())); !gobool(ok) { - return fmt.Errorf("Failed to link %s to %s", e.GetName(), elem.GetName()) + return fmt.Errorf("failed to link %s to %s", e.GetName(), elem.GetName()) } return nil } @@ -379,12 +379,12 @@ func (e *Element) Unlink(elem *Element) { func (e *Element) LinkFiltered(elem *Element, filter *Caps) error { if filter == nil { if ok := C.gst_element_link_filtered(e.Instance(), elem.Instance(), nil); !gobool(ok) { - return fmt.Errorf("Failed to link %s to %s with provided caps", e.GetName(), elem.GetName()) + return fmt.Errorf("failed to link %s to %s with provided caps", e.GetName(), elem.GetName()) } return nil } if ok := C.gst_element_link_filtered(e.Instance(), elem.Instance(), filter.Instance()); !gobool(ok) { - return fmt.Errorf("Failed to link %s to %s with provided caps", e.GetName(), elem.GetName()) + return fmt.Errorf("failed to link %s to %s with provided caps", e.GetName(), elem.GetName()) } return nil } @@ -454,7 +454,7 @@ func (e *Element) SendEvent(ev *Event) bool { func (e *Element) SetState(state State) error { stateRet := C.gst_element_set_state((*C.GstElement)(e.Instance()), C.GstState(state)) if stateRet == C.GST_STATE_CHANGE_FAILURE { - return fmt.Errorf("Failed to change state to %s", state.String()) + return fmt.Errorf("failed to change state to %s", state.String()) } return nil } diff --git a/gst/gst_mapinfo.go b/gst/gst_mapinfo.go index 494192d..189cac2 100644 --- a/gst/gst_mapinfo.go +++ b/gst/gst_mapinfo.go @@ -55,7 +55,7 @@ type mapInfoWriter struct { func (m *mapInfoWriter) Write(p []byte) (int, error) { if m.wsize+len(p) > int(m.mapInfo.Size()) { - return 0, errors.New("Attempt to write more data than allocated to MapInfo") + return 0, errors.New("attempt to write more data than allocated to MapInfo") } m.mapInfo.WriteAt(m.wsize, p) m.wsize += len(p) diff --git a/gst/gst_pad.go b/gst/gst_pad.go index 7fbd590..451ff02 100644 --- a/gst/gst_pad.go +++ b/gst/gst_pad.go @@ -1136,7 +1136,7 @@ func iteratorToPadSlice(iterator *C.GstIterator) ([]*Pad, error) { pads = append(pads, FromGstPadUnsafeNone(unsafe.Pointer(cPad))) C.g_value_unset((*C.GValue)(gval)) default: - return nil, errors.New("Pad iterator failed") + return nil, errors.New("pad iterator failed") } } } diff --git a/gst/gst_pipeline.go b/gst/gst_pipeline.go index 179bd12..8d0d81f 100644 --- a/gst/gst_pipeline.go +++ b/gst/gst_pipeline.go @@ -38,7 +38,7 @@ func NewPipeline(name string) (*Pipeline, error) { } pipeline := C.gst_pipeline_new((*C.gchar)(cChar)) if pipeline == nil { - return nil, errors.New("Could not create new pipeline") + return nil, errors.New("could not create new pipeline") } return FromGstPipelineUnsafeNone(unsafe.Pointer(pipeline)), nil } @@ -46,7 +46,7 @@ func NewPipeline(name string) (*Pipeline, error) { // NewPipelineFromString creates a new gstreamer pipeline from the given launch string. func NewPipelineFromString(launchv string) (*Pipeline, error) { if len(strings.Split(launchv, "!")) < 2 { - return nil, fmt.Errorf("Given string is too short for a pipeline: %s", launchv) + return nil, fmt.Errorf("given string is too short for a pipeline: %s", launchv) } cLaunchv := C.CString(launchv) defer C.free(unsafe.Pointer(cLaunchv)) diff --git a/gst/gst_registry.go b/gst/gst_registry.go index 46399c4..ca047c9 100644 --- a/gst/gst_registry.go +++ b/gst/gst_registry.go @@ -38,7 +38,7 @@ func (r *Registry) FindPlugin(name string) (*Plugin, error) { defer C.free(unsafe.Pointer(cName)) plugin := C.gst_registry_find_plugin((*C.GstRegistry)(r.Instance()), (*C.gchar)(cName)) if plugin == nil { - return nil, fmt.Errorf("No plugin named %s found", name) + return nil, fmt.Errorf("no plugin named %s found", name) } return FromGstPluginUnsafeFull(unsafe.Pointer(plugin)), nil } @@ -49,7 +49,7 @@ func (r *Registry) LookupFeature(name string) (*PluginFeature, error) { defer C.free(unsafe.Pointer(cName)) feat := C.gst_registry_lookup_feature((*C.GstRegistry)(r.Instance()), (*C.gchar)(cName)) if feat == nil { - return nil, fmt.Errorf("No feature named %s found", name) + return nil, fmt.Errorf("no feature named %s found", name) } return wrapPluginFeature(glib.TransferFull(unsafe.Pointer(feat))), nil } diff --git a/gst/gst_stream_collection.go b/gst/gst_stream_collection.go index 71aa135..387109c 100644 --- a/gst/gst_stream_collection.go +++ b/gst/gst_stream_collection.go @@ -40,7 +40,7 @@ func (s *StreamCollection) Instance() *C.GstStreamCollection { // AddStream adds the given stream to this collection. func (s *StreamCollection) AddStream(stream *Stream) error { if ok := gobool(C.gst_stream_collection_add_stream(s.Instance(), stream.Instance())); !ok { - return fmt.Errorf("Failed to add stream %s to collection", stream.StreamID()) + return fmt.Errorf("failed to add stream %s to collection", stream.StreamID()) } return nil } diff --git a/gst/gst_structure.go b/gst/gst_structure.go index 58e89d8..c5535e7 100644 --- a/gst/gst_structure.go +++ b/gst/gst_structure.go @@ -76,7 +76,7 @@ func FromGstStructureUnsafe(st unsafe.Pointer) *Structure { func (s *Structure) UnmarshalInto(data interface{}) error { rv := reflect.ValueOf(data) if rv.Kind() != reflect.Ptr || rv.IsNil() { - return errors.New("Data is invalid (nil or non-pointer)") + return errors.New("data is invalid (nil or non-pointer)") } val := reflect.ValueOf(data).Elem() @@ -134,7 +134,7 @@ func (s *Structure) GetValue(key string) (interface{}, error) { defer C.free(unsafe.Pointer(cKey)) gVal := C.gst_structure_get_value(s.Instance(), cKey) if gVal == nil { - return nil, fmt.Errorf("No value exists at %s", key) + return nil, fmt.Errorf("no value exists at %s", key) } return glib.ValueFromNative(unsafe.Pointer(gVal)).GoValue() }