Skip to content

pkg/pdfcpu/form: FieldType should follow the Stringer interface #765

@sbourlon

Description

@sbourlon
  • Your issue is based on the latest commit
 % git --no-pager log --oneline -1
e33b502 (HEAD -> master, sbourlon/master, origin/master, origin/HEAD) Fix #755
  • State your OS and OS version
 % lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.10
Release:        23.10
Codename:       mantic

Hello Horst, I am using pdfcpu as a library. I found that the FieldType structure in the form package is not following the standard Stringer interface to stringify itself.

Using the stringer interface is a good practice so external packages can print (fmt.Printf("%s", fieldType)) and access its string representation.

Source : The Stringer interface from the fmt package (https://pkg.go.dev/fmt#Stringer)

I created on fix on my fork if you are interested: 7576369.

I think that this fix is low risk because the current string() method is called only twice in the form package.

 % pwd
/home/stefan/Local/src/github.com/pdfcpu/pdfcpu

% rg "\.string"
pkg/pdfcpu/form/form.go
775:                    t := f.Typ.string()
848:            t := f.Typ.string()

pkg/pdfcpu/types/array.go
31:func NewStringLiteralArray(sVars ...string) Array {
43:func NewHexLiteralArray(sVars ...string) Array {
55:func NewNameArray(sVars ...string) Array {

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions