From 7e69df88eac0c1d38397b3bf1f01ab5c646073e7 Mon Sep 17 00:00:00 2001
From: Alexander Pikeev
Date: Thu, 31 Oct 2024 14:32:46 +0300
Subject: [PATCH] feat: return v8 in module name
---
Makefile | 2 +-
README.md | 85 +++++++++++++++++---------------
baserequest.go | 2 +-
build/tests/docker-entrypoint.sh | 2 +-
chromium.go | 2 +-
go.mod | 2 +-
html.go | 2 +-
html_test.go | 4 +-
libreoffice.go | 2 +-
libreoffice_test.go | 4 +-
markdown.go | 2 +-
markdown_test.go | 4 +-
metadata_reader.go | 2 +-
metadata_test.go | 4 +-
metadata_writer.go | 2 +-
multipart.go | 2 +-
pdfengines.go | 2 +-
pdfengines_test.go | 4 +-
url.go | 2 +-
url_test.go | 4 +-
20 files changed, 71 insertions(+), 64 deletions(-)
diff --git a/Makefile b/Makefile
index 9d6f214..e43affe 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ GOTENBERG_VERSION=8.12.0
GOTENBERG_LOG_LEVEL=ERROR
VERSION=snapshot
GOLANGCI_LINT_VERSION=1.61.0
-REPO=dcaraxes/gotenberg-go-client
+REPO=dcaraxes/gotenberg-go-client/v8
# gofmt and goimports all go files.
fmt:
diff --git a/README.md b/README.md
index 8cb95b6..806b25b 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,15 @@
Gotenberg Go Client
The Go client for interacting with a Gotenberg API. This project is a further development of the client from TheCodingMachine, which does not support the new functionality since version 7 of Gotenberg.
-
---
-|Gotenberg version |Client version |
-|:----------------:|:---------------------------------------------------------------------------------------------------------:|
-|`8.x` **(actual)**|`8.6.2` **(actual)** |
-|`7.x` |`<= 8.5.0` |
-|`6.x` |thecodingmachine/gotenberg-go-client |
+|Gotenberg version | Client version |
+|:----------------:|:----------------------------------------------------------------------------------------------------------:|
+|`8.x` **(actual)**| `8.6.3` **(actual)**
|
+|`7.x` | `<= 8.5.0` |
+|`6.x` | thecodingmachine/gotenberg-go-client |
---
@@ -19,7 +18,7 @@
To get the latest version of the client:
```zsh
-$ go get github.com/dcaraxes/gotenberg-go-client@latest
+$ go get github.com/dcaraxes/gotenberg-go-client/v8@latest
```
## Preparing a documents
@@ -28,10 +27,11 @@ $ go get github.com/dcaraxes/gotenberg-go-client@latest
package main
import (
+ "net/http"
"os"
- "github.com/dcaraxes/gotenberg-go-client"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
func main() {
@@ -51,7 +51,9 @@ func main() {
## Converting HTML to PDF
> [!TIP]
-> Head to the [documentation](https://gotenberg.dev/) to learn about all request parameters. For the PaperSize method, you can use predefined parameters such as gotenberg.A4, gotenberg.A3 and so on. The full list of predefined parameters can be found in [types file](https://github.com/dcaraxes/gotenberg-go-client/blob/beta-8.6/types.go).
+> Head to the [documentation](https://gotenberg.dev/) to learn about all request parameters. For the PaperSize
+> method, you can use predefined parameters such as gotenberg.A4, gotenberg.A3 and so on. The full list of
+> predefined parameters can be found in [types file](https://github.com/dcaraxes/gotenberg-go-client/v8/blob/master/types.go).
> [!IMPORTANT]
> To use basic authorization, you must run Gotenberg with the --api-enable-basic-auth flag and have GOTENBERG_API_BASIC_AUTH_USERNAME and GOTENBERG_API_BASIC_AUTH_PASSWORD environment variables.
@@ -60,10 +62,11 @@ func main() {
package main
import (
+ "context"
"net/http"
- "github.com/dcaraxes/gotenberg-go-client"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
func main() {
@@ -94,10 +97,10 @@ func main() {
req.SkipNetworkIdleEvent()
// Store method allows you to store the resulting PDF in a particular destination.
- client.Store(req, "path/to/store.pdf")
+ err := client.Store(context.Background(), req, "path/to/store.pdf")
// If you wish to redirect the response directly to the browser, you may also use:
- resp, err := client.Send(req)
+ resp, err := client.Send(context.Background(), req)
}
```
@@ -114,10 +117,12 @@ Reading metadata available only for PDF files, but you can write metadata to all
package main
import (
+ "context"
+ "encoding/json"
"net/http"
- "github.com/dcaraxes/gotenberg-go-client"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
func main() {
@@ -141,7 +146,7 @@ func main() {
md, err := json.Marshal(data)
req.Metadata(md)
- resp, err := client.Send(req)
+ resp, err := client.Send(context.Background(), req)
}
```
@@ -151,31 +156,32 @@ func main() {
package main
import (
- "encoding/json"
- "net/http"
+ "context"
+ "encoding/json"
+ "net/http"
- "github.com/dcaraxes/gotenberg-go-client"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
func main() {
- client, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)
+ client, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)
- // Prepare the files required for your conversion.
- doc, err := document.FromPath("filename.ext", "/path/to/file")
- req := gotenberg.NewReadMetadataRequest(doc)
+ // Prepare the files required for your conversion.
+ doc, err := document.FromPath("filename.ext", "/path/to/file")
+ req := gotenberg.NewReadMetadataRequest(doc)
- resp, err := client.Send(req)
+ resp, err := client.Send(context.Background(), req)
- var data = struct {
- FooPdf struct {
- Author string `json:"Author"`
- Copyright string `json:"Copyright"`
- } `json:"foo.pdf"`
- }
+ var data = struct {
+ FooPdf struct {
+ Author string `json:"Author"`
+ Copyright string `json:"Copyright"`
+ } `json:"foo.pdf"`
+ }
- // Decode metadata into a struct.
- err = json.NewDecoder(resp.Body).Decode(&data)
+ // Decode metadata into a struct.
+ err = json.NewDecoder(resp.Body).Decode(&data)
}
```
@@ -189,14 +195,15 @@ func main() {
package main
import (
+ "context"
"net/http"
- "github.com/dcaraxes/gotenberg-go-client"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
func main() {
- c, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)
+ client, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)
index, err := document.FromPath("index.html", "/path/to/file")
@@ -204,11 +211,11 @@ func main() {
req := gotenberg.NewHTMLRequest(index)
req.Format(gotenberg.JPEG)
- resp, err := client.Screenshot(req)
+ resp, err := client.Screenshot(context.Background(), req)
}
```
---
-**For more complete usages, head to the [documentation](https://gotenberg.dev/).**
+**For more complete usages, head to the [documentation](https://gotenberg.dev/).**
\ No newline at end of file
diff --git a/baserequest.go b/baserequest.go
index a63e812..6b167a4 100644
--- a/baserequest.go
+++ b/baserequest.go
@@ -5,7 +5,7 @@ import (
"encoding/json"
"net/http"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
type baseRequester interface {
diff --git a/build/tests/docker-entrypoint.sh b/build/tests/docker-entrypoint.sh
index 0aa3860..401236f 100755
--- a/build/tests/docker-entrypoint.sh
+++ b/build/tests/docker-entrypoint.sh
@@ -6,5 +6,5 @@ set -xe
gotenberg --api-enable-basic-auth &
sleep 10
export CGO_ENABLED=1
-go test -race -cover -covermode=atomic github.com/dcaraxes/gotenberg-go-client
+go test -race -cover -covermode=atomic github.com/dcaraxes/gotenberg-go-client/v8
sleep 10 # allows Gotenberg to remove generated files.
\ No newline at end of file
diff --git a/chromium.go b/chromium.go
index 290df49..f64ac15 100644
--- a/chromium.go
+++ b/chromium.go
@@ -5,7 +5,7 @@ import (
"strconv"
"time"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
type chromiumRequest struct {
diff --git a/go.mod b/go.mod
index 226e062..2027ed6 100644
--- a/go.mod
+++ b/go.mod
@@ -8,4 +8,4 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
-)
+)
\ No newline at end of file
diff --git a/html.go b/html.go
index cc842e1..38b22f7 100644
--- a/html.go
+++ b/html.go
@@ -1,6 +1,6 @@
package gotenberg
-import "github.com/dcaraxes/gotenberg-go-client/document"
+import "github.com/dcaraxes/gotenberg-go-client/v8/document"
const (
endpointHTMLConvert = "/forms/chromium/convert/html"
diff --git a/html_test.go b/html_test.go
index 2ff5866..93d8243 100644
--- a/html_test.go
+++ b/html_test.go
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/dcaraxes/gotenberg-go-client/document"
- "github.com/dcaraxes/gotenberg-go-client/test"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/test"
)
func TestHTML(t *testing.T) {
diff --git a/libreoffice.go b/libreoffice.go
index 463ed9a..23b01c6 100644
--- a/libreoffice.go
+++ b/libreoffice.go
@@ -3,7 +3,7 @@ package gotenberg
import (
"strconv"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
const endpointOfficeConvert = "/forms/libreoffice/convert"
diff --git a/libreoffice_test.go b/libreoffice_test.go
index 2377457..68121c5 100644
--- a/libreoffice_test.go
+++ b/libreoffice_test.go
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/dcaraxes/gotenberg-go-client/document"
- "github.com/dcaraxes/gotenberg-go-client/test"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/test"
)
func TestOffice(t *testing.T) {
diff --git a/markdown.go b/markdown.go
index b10f72d..d55107a 100644
--- a/markdown.go
+++ b/markdown.go
@@ -1,6 +1,6 @@
package gotenberg
-import "github.com/dcaraxes/gotenberg-go-client/document"
+import "github.com/dcaraxes/gotenberg-go-client/v8/document"
const (
endpointMarkdownConvert = "/forms/chromium/convert/markdown"
diff --git a/markdown_test.go b/markdown_test.go
index 4bd79ee..ef576f5 100644
--- a/markdown_test.go
+++ b/markdown_test.go
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/dcaraxes/gotenberg-go-client/document"
- "github.com/dcaraxes/gotenberg-go-client/test"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/test"
)
func TestMarkdown(t *testing.T) {
diff --git a/metadata_reader.go b/metadata_reader.go
index d6a8a08..b6ec1e7 100644
--- a/metadata_reader.go
+++ b/metadata_reader.go
@@ -1,6 +1,6 @@
package gotenberg
-import "github.com/dcaraxes/gotenberg-go-client/document"
+import "github.com/dcaraxes/gotenberg-go-client/v8/document"
type ReadMetadataRequest struct {
pdfs []document.Document
diff --git a/metadata_test.go b/metadata_test.go
index ac57cfd..64566da 100644
--- a/metadata_test.go
+++ b/metadata_test.go
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/dcaraxes/gotenberg-go-client/document"
- "github.com/dcaraxes/gotenberg-go-client/test"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/test"
)
func TestReadWriteMetadata(t *testing.T) {
diff --git a/metadata_writer.go b/metadata_writer.go
index e45cc69..b36a70e 100644
--- a/metadata_writer.go
+++ b/metadata_writer.go
@@ -1,6 +1,6 @@
package gotenberg
-import "github.com/dcaraxes/gotenberg-go-client/document"
+import "github.com/dcaraxes/gotenberg-go-client/v8/document"
type WriteMetadataRequest struct {
pdfs []document.Document
diff --git a/multipart.go b/multipart.go
index cc57251..79214a9 100644
--- a/multipart.go
+++ b/multipart.go
@@ -6,7 +6,7 @@ import (
"io"
"mime/multipart"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
func multipartForm(r baseRequester) (body *bytes.Buffer, contentType string, err error) {
diff --git a/pdfengines.go b/pdfengines.go
index 6c5b74b..9a84a61 100644
--- a/pdfengines.go
+++ b/pdfengines.go
@@ -3,7 +3,7 @@ package gotenberg
import (
"strconv"
- "github.com/dcaraxes/gotenberg-go-client/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
)
// MergeRequest facilitates work with PDF files with the Gotenberg API.
diff --git a/pdfengines_test.go b/pdfengines_test.go
index f06acf6..c7ae283 100644
--- a/pdfengines_test.go
+++ b/pdfengines_test.go
@@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/dcaraxes/gotenberg-go-client/document"
- "github.com/dcaraxes/gotenberg-go-client/test"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/test"
)
func TestMerge(t *testing.T) {
diff --git a/url.go b/url.go
index e6dd072..6f56383 100644
--- a/url.go
+++ b/url.go
@@ -1,6 +1,6 @@
package gotenberg
-import "github.com/dcaraxes/gotenberg-go-client/document"
+import "github.com/dcaraxes/gotenberg-go-client/v8/document"
const (
endpointURLConvert = "/forms/chromium/convert/url"
diff --git a/url_test.go b/url_test.go
index 060fde5..e6f679e 100644
--- a/url_test.go
+++ b/url_test.go
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "github.com/dcaraxes/gotenberg-go-client/document"
- "github.com/dcaraxes/gotenberg-go-client/test"
+ "github.com/dcaraxes/gotenberg-go-client/v8/document"
+ "github.com/dcaraxes/gotenberg-go-client/v8/test"
)
func TestURL(t *testing.T) {