mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
Address go vet issues
This commit is contained in:
parent
2adbc645ad
commit
22c2e5eb41
@ -46,6 +46,7 @@ func (this *ContentStreamParser) Parse() (*ContentStreamOperations, error) {
|
||||
obj, err, isOperand := this.parseObject()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
// End of data. Successful exit point.
|
||||
return &operations, nil
|
||||
}
|
||||
return &operations, err
|
||||
@ -69,9 +70,6 @@ func (this *ContentStreamParser) Parse() (*ContentStreamOperations, error) {
|
||||
operation.Params = append(operation.Params, im)
|
||||
}
|
||||
}
|
||||
|
||||
common.Log.Debug("Operation list: %v\n", operations)
|
||||
return &operations, nil
|
||||
}
|
||||
|
||||
// Skip over any spaces. Returns the number of spaces skipped and
|
||||
|
@ -7,7 +7,6 @@ package contentstream
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/unidoc/unidoc/common"
|
||||
. "github.com/unidoc/unidoc/pdf/core"
|
||||
@ -25,10 +24,6 @@ type GraphicsState struct {
|
||||
|
||||
type GraphicStateStack []GraphicsState
|
||||
|
||||
func (gs *GraphicsState) String() string {
|
||||
return fmt.Sprintf("%+v", gs)
|
||||
}
|
||||
|
||||
func (gsStack *GraphicStateStack) Push(gs GraphicsState) {
|
||||
*gsStack = append(*gsStack, gs)
|
||||
}
|
||||
|
@ -570,8 +570,6 @@ func (parser *PdfParser) parseObject() (PdfObject, error) {
|
||||
return nil, errors.New("Object parsing error - unexpected pattern")
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("Object parsing error - unexpected pattern")
|
||||
}
|
||||
|
||||
// Reads and parses a PDF dictionary object enclosed with '<<' and '>>'
|
||||
@ -657,13 +655,12 @@ func (parser *PdfParser) parsePdfVersion() (int, int, error) {
|
||||
result1 := rePdfVersion.FindStringSubmatch(string(b))
|
||||
if len(result1) < 3 {
|
||||
major, minor, err := parser.seekPdfVersionTopDown()
|
||||
if err == nil {
|
||||
if err != nil {
|
||||
common.Log.Debug("Failed recovery - unable to find version")
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return major, minor, nil
|
||||
return 0, 0, errors.New("PDF version not found")
|
||||
}
|
||||
|
||||
majorVersion, err := strconv.ParseInt(result1[1], 10, 64)
|
||||
|
@ -151,7 +151,7 @@ func TestBoolParsing(t *testing.T) {
|
||||
return
|
||||
}
|
||||
if bool(val) != expected {
|
||||
t.Errorf("bool not as expected (%b)", val)
|
||||
t.Errorf("bool not as expected (got %t, expected %t)", bool(val), expected)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,7 @@ func TestNumericParsing1(t *testing.T) {
|
||||
return
|
||||
}
|
||||
if float32(*num) != val {
|
||||
t.Errorf("Idx %d, value incorrect (%f)", idx)
|
||||
t.Errorf("Idx %d, value incorrect (%f)", idx, val)
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ func TestNumericParsing2(t *testing.T) {
|
||||
return
|
||||
}
|
||||
if float32(*num) != val {
|
||||
t.Errorf("Idx %d, value incorrect (%f)", idx)
|
||||
t.Errorf("Idx %d, value incorrect (%f)", idx, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ func TestNumericParsing3(t *testing.T) {
|
||||
return
|
||||
}
|
||||
if float32(*num) != val {
|
||||
t.Errorf("Idx %d, value incorrect (%f)", idx)
|
||||
t.Errorf("Idx %d, value incorrect (%f)", idx, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ func (this *Image) ToGoImage() (goimage.Image, error) {
|
||||
b := uint16(samples[i+4])<<8 | uint16(samples[i+5])
|
||||
a := uint16(0)
|
||||
if this.alphaData != nil && len(this.alphaData) > aidx+1 {
|
||||
a = uint16(this.alphaData[aidx]<<8) | uint16(this.alphaData[aidx+1])
|
||||
a = (uint16(this.alphaData[aidx]) << 8) | uint16(this.alphaData[aidx+1])
|
||||
aidx += 2
|
||||
}
|
||||
c = gocolor.RGBA64{R: r, G: g, B: b, A: a}
|
||||
|
Loading…
x
Reference in New Issue
Block a user