Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sbourlon opened this issue Jan 5, 2024 · 2 comments
Closed

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

sbourlon opened this issue Jan 5, 2024 · 2 comments
Assignees

Comments

@sbourlon
Copy link

sbourlon commented Jan 5, 2024

  • 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 {
@hhrutter
Copy link
Collaborator

hhrutter commented Jan 8, 2024

Thanks for reporting this!

@hhrutter
Copy link
Collaborator

hhrutter commented Mar 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants