mirror of
https://github.com/axllent/goptimize.git
synced 2024-09-27 13:15:55 -04:00
Use os.CreateTemp() rather than ioutil.TempFile()
This commit is contained in:
parent
e8c7298c9c
commit
ea2d490686
@ -6,7 +6,6 @@ import (
|
|||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -83,7 +82,7 @@ func Goptimize(file string) {
|
|||||||
resultW := dstBounds.Dx()
|
resultW := dstBounds.Dx()
|
||||||
resultH := dstBounds.Dy()
|
resultH := dstBounds.Dy()
|
||||||
|
|
||||||
tmpFile, err := ioutil.TempFile(os.TempDir(), "Goptimized-")
|
tmpFile, err := os.CreateTemp(os.TempDir(), "Goptimized-")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error: cannot create temporary file: %v\n", err)
|
fmt.Printf("Error: cannot create temporary file: %v\n", err)
|
||||||
@ -227,7 +226,7 @@ func Goptimize(file string) {
|
|||||||
// and overwrite it if the output is smaller than the original
|
// and overwrite it if the output is smaller than the original
|
||||||
func RunOptimizer(src string, outFileArg bool, args ...string) {
|
func RunOptimizer(src string, outFileArg bool, args ...string) {
|
||||||
// create a new temp file
|
// create a new temp file
|
||||||
tmpFile, err := ioutil.TempFile(os.TempDir(), "Goptimized-")
|
tmpFile, err := os.CreateTemp(os.TempDir(), "Goptimized-")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Cannot create temporary file: %v\n", err)
|
fmt.Printf("Cannot create temporary file: %v\n", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user