mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:51:44 +08:00
refactor: move from io/ioutil to io and os packages
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
parent
ae341be638
commit
ef8d7d2fd7
13
cmd/fs.go
13
cmd/fs.go
@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
@ -50,7 +49,7 @@ func (fs *FSHelper) FileExists(path string) bool {
|
||||
|
||||
// FindFile returns the first occurrence of match inside path.
|
||||
func (fs *FSHelper) FindFile(path, match string) (string, error) {
|
||||
files, err := ioutil.ReadDir(path)
|
||||
files, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -69,7 +68,7 @@ func (fs *FSHelper) FindFile(path, match string) (string, error) {
|
||||
func (fs *FSHelper) CreateFile(filename string, data []byte) error {
|
||||
// Ensure directory exists
|
||||
fs.MkDirs(filepath.Dir(filename))
|
||||
return ioutil.WriteFile(filename, data, 0644)
|
||||
return os.WriteFile(filename, data, 0644)
|
||||
}
|
||||
|
||||
// MkDirs creates the given nested directories.
|
||||
@ -156,14 +155,14 @@ func (fs *FSHelper) LoadRelativeFile(relativePath string) ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadFile(fullPath)
|
||||
return os.ReadFile(fullPath)
|
||||
}
|
||||
|
||||
// GetSubdirs will return a list of FQPs to subdirectories in the given directory
|
||||
func (d *Dir) GetSubdirs() (map[string]string, error) {
|
||||
|
||||
// Read in the directory information
|
||||
fileInfo, err := ioutil.ReadDir(d.fullPath)
|
||||
fileInfo, err := os.ReadDir(d.fullPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -215,7 +214,7 @@ func (fs *FSHelper) SaveAsJSON(data interface{}, filename string) error {
|
||||
e.SetIndent("", " ")
|
||||
e.Encode(data)
|
||||
|
||||
err := ioutil.WriteFile(filename, buf.Bytes(), 0755)
|
||||
err := os.WriteFile(filename, buf.Bytes(), 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -231,7 +230,7 @@ func (fs *FSHelper) LoadAsString(filename string) (string, error) {
|
||||
|
||||
// LoadAsBytes returns the contents of the file as a byte slice
|
||||
func (fs *FSHelper) LoadAsBytes(filename string) ([]byte, error) {
|
||||
return ioutil.ReadFile(filename)
|
||||
return os.ReadFile(filename)
|
||||
}
|
||||
|
||||
// FileMD5 returns the md5sum of the given file
|
||||
|
@ -3,7 +3,7 @@ package cmd
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
)
|
||||
@ -28,7 +28,7 @@ func (g *GitHubHelper) GetVersionTags() ([]*SemanticVersion, error) {
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
@ -95,7 +94,7 @@ func GetLinuxDistroInfo() *DistroInfo {
|
||||
}
|
||||
_, err := os.Stat("/etc/os-release")
|
||||
if !os.IsNotExist(err) {
|
||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||
osRelease, _ := os.ReadFile("/etc/os-release")
|
||||
result = parseOsRelease(string(osRelease))
|
||||
}
|
||||
return result
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@ -244,7 +243,7 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||
// No - create a new plist from our defaults
|
||||
tmpl := template.New("infoPlist")
|
||||
plistFile := filepath.Join(b.getPackageFileBaseDir(), "info.plist")
|
||||
infoPlist, err := ioutil.ReadFile(plistFile)
|
||||
infoPlist, err := os.ReadFile(plistFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -258,13 +257,13 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||
}
|
||||
|
||||
// Save to the package
|
||||
err = ioutil.WriteFile(plistFilename, tpl.Bytes(), 0644)
|
||||
err = os.WriteFile(plistFilename, tpl.Bytes(), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Also write to project directory for customisation
|
||||
err = ioutil.WriteFile(customPlist, tpl.Bytes(), 0644)
|
||||
err = os.WriteFile(customPlist, tpl.Bytes(), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -334,12 +333,12 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||
tgtRCFile := filepath.Join(outputDir, basename+".rc")
|
||||
if !b.fs.FileExists(tgtRCFile) {
|
||||
srcRCfile := filepath.Join(b.getPackageFileBaseDir(), "wails.rc")
|
||||
rcfilebytes, err := ioutil.ReadFile(srcRCfile)
|
||||
rcfilebytes, err := os.ReadFile(srcRCfile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rcfiledata := strings.Replace(string(rcfilebytes), "$NAME$", basename, -1)
|
||||
err = ioutil.WriteFile(tgtRCFile, []byte(rcfiledata), 0755)
|
||||
err = os.WriteFile(tgtRCFile, []byte(rcfiledata), 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -387,11 +386,11 @@ func (b *PackageHelper) copyIcon() (string, error) {
|
||||
|
||||
// Install default icon
|
||||
iconfile := filepath.Join(b.getPackageFileBaseDir(), "icon.png")
|
||||
iconData, err := ioutil.ReadFile(iconfile)
|
||||
iconData, err := os.ReadFile(iconfile)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = ioutil.WriteFile(srcIcon, iconData, 0644)
|
||||
err = os.WriteFile(srcIcon, iconData, 0644)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package cmd
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -310,14 +309,14 @@ func (po *ProjectOptions) WriteProjectConfig() error {
|
||||
return err
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(targetFile, filedata, 0600)
|
||||
return os.WriteFile(targetFile, filedata, 0600)
|
||||
}
|
||||
|
||||
// LoadConfig loads the project configuration file from the
|
||||
// given directory
|
||||
func (po *ProjectOptions) LoadConfig(projectDir string) error {
|
||||
targetFile := filepath.Join(projectDir, "project.json")
|
||||
rawBytes, err := ioutil.ReadFile(targetFile)
|
||||
rawBytes, err := os.ReadFile(targetFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package cmd
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -124,7 +123,7 @@ func (s *SystemHelper) setup() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(s.wailsSystemConfig, configData, 0755)
|
||||
err = os.WriteFile(s.wailsSystemConfig, configData, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -207,11 +206,11 @@ func (sc *SystemConfig) Save(filename string) error {
|
||||
}
|
||||
|
||||
// Write it out to the config file
|
||||
return ioutil.WriteFile(filename, theJSON, 0644)
|
||||
return os.WriteFile(filename, theJSON, 0644)
|
||||
}
|
||||
|
||||
func (sc *SystemConfig) load(filename string) error {
|
||||
configData, err := ioutil.ReadFile(filename)
|
||||
configData, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -125,7 +125,7 @@ func (t *TemplateHelper) LoadMetadata(dir string) (*TemplateMetadata, error) {
|
||||
if !t.fs.FileExists(templateFile) {
|
||||
return nil, nil
|
||||
}
|
||||
rawJSON, err := ioutil.ReadFile(templateFile)
|
||||
rawJSON, err := os.ReadFile(templateFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -305,7 +304,7 @@ func updateWailsVersion(currentVersion, latestVersion *semver.Version) error {
|
||||
new := fmt.Sprintf("%s v%s", wailsModule, latestVersion)
|
||||
|
||||
goMod = strings.Replace(goMod, old, new, -1)
|
||||
err := ioutil.WriteFile(goModFile, []byte(goMod), 0600)
|
||||
err := os.WriteFile(goModFile, []byte(goMod), 0600)
|
||||
if err != nil {
|
||||
checkSpinner.Error()
|
||||
return err
|
||||
@ -343,7 +342,7 @@ func patchMainJS() error {
|
||||
newStartLine := `Wails.Init`
|
||||
mainJSContents = strings.Replace(mainJSContents, oldStartLine, newStartLine, -1)
|
||||
|
||||
err := ioutil.WriteFile(mainJSFile, []byte(mainJSContents), 0600)
|
||||
err := os.WriteFile(mainJSFile, []byte(mainJSContents), 0600)
|
||||
if err != nil {
|
||||
checkSpinner.Error()
|
||||
return err
|
||||
|
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -112,7 +112,7 @@ To help you in this process, we will ask for some information, add Go/Wails deta
|
||||
os.Exit(1)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
template, _ := ioutil.ReadAll(resp.Body)
|
||||
template, _ := io.ReadAll(resp.Body)
|
||||
body := string(template)
|
||||
body = "**Description**\n" + (strings.Split(body, "**Description**")[1])
|
||||
fullURL := "https://github.com/wailsapp/wails/issues/new?"
|
||||
|
@ -2,7 +2,6 @@ package binding
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@ -144,7 +143,7 @@ export {};`
|
||||
|
||||
dir := filepath.Dir(typescriptDefinitionFilename)
|
||||
os.MkdirAll(dir, 0755)
|
||||
return ioutil.WriteFile(typescriptDefinitionFilename, []byte(output.String()), 0755)
|
||||
return os.WriteFile(typescriptDefinitionFilename, []byte(output.String()), 0755)
|
||||
}
|
||||
|
||||
// bind the given struct method
|
||||
|
@ -4,15 +4,14 @@ import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/go-git/go-git/v5"
|
||||
gofs "io/fs"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/leaanthony/debme"
|
||||
@ -295,7 +294,7 @@ func Install(options *Options) (bool, *Template, error) {
|
||||
// Clones the given uri and returns the temporary cloned directory
|
||||
func gitclone(options *Options) (string, error) {
|
||||
// Create temporary directory
|
||||
dirname, err := ioutil.TempDir("", "wails-template-*")
|
||||
dirname, err := os.MkdirTemp("", "wails-template-*")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -126,7 +125,7 @@ func RelativePath(relativepath string, optionalpaths ...string) string {
|
||||
// MustLoadString attempts to load a string and will abort with a fatal message if
|
||||
// something goes wrong
|
||||
func MustLoadString(filename string) string {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
data, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
fmt.Printf("FATAL: Unable to load file '%s': %s\n", filename, err.Error())
|
||||
os.Exit(1)
|
||||
@ -163,7 +162,7 @@ func MustMD5File(filename string) string {
|
||||
// MustWriteString will attempt to write the given data to the given filename
|
||||
// It will abort the program in the event of a failure
|
||||
func MustWriteString(filename string, data string) {
|
||||
err := ioutil.WriteFile(filename, []byte(data), 0755)
|
||||
err := os.WriteFile(filename, []byte(data), 0755)
|
||||
if err != nil {
|
||||
fatal("Unable to write file", filename, ":", err.Error())
|
||||
os.Exit(1)
|
||||
@ -244,7 +243,7 @@ func CopyDir(src string, dst string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
entries, err := ioutil.ReadDir(src)
|
||||
entries, err := os.ReadDir(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -260,7 +259,7 @@ func CopyDir(src string, dst string) (err error) {
|
||||
}
|
||||
} else {
|
||||
// Skip symlinks.
|
||||
if entry.Mode()&os.ModeSymlink != 0 {
|
||||
if entry.Type()&os.ModeSymlink != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -306,7 +305,7 @@ func CopyDirExtended(src string, dst string, ignore []string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
entries, err := ioutil.ReadDir(src)
|
||||
entries, err := os.ReadDir(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -325,7 +324,7 @@ func CopyDirExtended(src string, dst string, ignore []string) (err error) {
|
||||
}
|
||||
} else {
|
||||
// Skip symlinks.
|
||||
if entry.Mode()&os.ModeSymlink != 0 {
|
||||
if entry.Type()&os.ModeSymlink != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -370,7 +369,7 @@ func MoveDirExtended(src string, dst string, ignore []string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
entries, err := ioutil.ReadDir(src)
|
||||
entries, err := os.ReadDir(src)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -383,7 +382,7 @@ func MoveDirExtended(src string, dst string, ignore []string) (err error) {
|
||||
dstPath := filepath.Join(dst, entry.Name())
|
||||
|
||||
// Skip symlinks.
|
||||
if entry.Mode()&os.ModeSymlink != 0 {
|
||||
if entry.Type()&os.ModeSymlink != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package github
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
@ -20,7 +20,7 @@ func GetVersionTags() ([]*SemanticVersion, error) {
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package html
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
@ -39,7 +39,7 @@ type Asset struct {
|
||||
// Load the asset from disk
|
||||
func (a *Asset) Load(basedirectory string) error {
|
||||
assetpath := filepath.Join(basedirectory, a.Path)
|
||||
data, err := ioutil.ReadFile(assetpath)
|
||||
data, err := os.ReadFile(assetpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@ -189,7 +189,7 @@ func (a *AssetBundle) WriteToCFile(targetDir string) (string, error) {
|
||||
|
||||
// Save file
|
||||
assetsFile := filepath.Join(targetDir, "assets.h")
|
||||
err = ioutil.WriteFile(assetsFile, []byte(cdata.String()), 0600)
|
||||
err = os.WriteFile(assetsFile, []byte(cdata.String()), 0600)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package project
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -77,7 +76,7 @@ func Load(projectPath string) (*Project, error) {
|
||||
|
||||
// Attempt to load project.json
|
||||
projectFile := filepath.Join(projectPath, "wails.json")
|
||||
rawBytes, err := ioutil.ReadFile(projectFile)
|
||||
rawBytes, err := os.ReadFile(projectFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
@ -51,7 +50,7 @@ func main() {
|
||||
}
|
||||
|
||||
wailsJS := fs.RelativePath("../assets/desktop_" + platform + ".js")
|
||||
runtimeData, err := ioutil.ReadFile(wailsJS)
|
||||
runtimeData, err := os.ReadFile(wailsJS)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -78,7 +77,7 @@ const unsigned char runtime[]={`
|
||||
// Save file
|
||||
outputFile := fs.RelativePath(fmt.Sprintf("../../ffenestri/runtime_%s.c", platform))
|
||||
|
||||
if err := ioutil.WriteFile(outputFile, []byte(runtimeC), 0600); err != nil {
|
||||
if err := os.WriteFile(outputFile, []byte(runtimeC), 0600); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ package operatingsystem
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
@ -17,7 +16,7 @@ func platformInfo() (*OS, error) {
|
||||
return nil, fmt.Errorf("unable to read system information")
|
||||
}
|
||||
|
||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||
osRelease, _ := os.ReadFile("/etc/os-release")
|
||||
return parseOsRelease(string(osRelease)), nil
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package build
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -87,7 +86,7 @@ func (b *BaseBuilder) buildCustomAssets(projectData *project.Project) error {
|
||||
if len(localPath) == 0 {
|
||||
return nil
|
||||
}
|
||||
if data, err := ioutil.ReadFile(filepath.Join(customAssetsDir, localPath)); err == nil {
|
||||
if data, err := os.ReadFile(filepath.Join(customAssetsDir, localPath)); err == nil {
|
||||
assets.AddAsset(localPath, data)
|
||||
}
|
||||
|
||||
@ -100,7 +99,7 @@ func (b *BaseBuilder) buildCustomAssets(projectData *project.Project) error {
|
||||
// Write assetdb out to root directory
|
||||
assetsDbFilename := fs.RelativePath("../../../assetsdb.go")
|
||||
b.addFileToDelete(assetsDbFilename)
|
||||
err = ioutil.WriteFile(assetsDbFilename, []byte(assets.Serialize("assets", "wails")), 0644)
|
||||
err = os.WriteFile(assetsDbFilename, []byte(assets.Serialize("assets", "wails")), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -108,7 +107,7 @@ func (b *BaseBuilder) buildCustomAssets(projectData *project.Project) error {
|
||||
}
|
||||
|
||||
func (b *BaseBuilder) convertFileToIntegerString(filename string) (string, error) {
|
||||
rawData, err := ioutil.ReadFile(filename)
|
||||
rawData, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/wailsapp/wails/v2/pkg/buildassets"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/fs"
|
||||
"github.com/wailsapp/wails/v2/internal/html"
|
||||
"github.com/wailsapp/wails/v2/pkg/buildassets"
|
||||
)
|
||||
|
||||
// DesktopBuilder builds applications for the desktop
|
||||
@ -138,7 +138,7 @@ func (d *DesktopBuilder) BuildRuntime(options *Options) error {
|
||||
}
|
||||
|
||||
wailsJS := fs.RelativePath("../../../internal/runtime/assets/desktop.js")
|
||||
runtimeData, err := ioutil.ReadFile(wailsJS)
|
||||
runtimeData, err := os.ReadFile(wailsJS)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -158,7 +158,7 @@ const unsigned char runtime[]={`
|
||||
// Save file
|
||||
outputFile := fs.RelativePath("../../../internal/ffenestri/runtime.c")
|
||||
|
||||
if err := ioutil.WriteFile(outputFile, []byte(runtimeC), 0600); err != nil {
|
||||
if err := os.WriteFile(outputFile, []byte(runtimeC), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -75,7 +74,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
||||
for count, filename := range trayIconFilenames {
|
||||
|
||||
// Load the tray icon
|
||||
dataBytes, err = ioutil.ReadFile(filename)
|
||||
dataBytes, err = os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -110,7 +109,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
||||
}
|
||||
cdata.WriteString("0x00 };\n")
|
||||
|
||||
err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
err = os.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -169,7 +168,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
|
||||
for count, filename := range dialogIconFilenames {
|
||||
|
||||
// Load the tray icon
|
||||
dataBytes, err = ioutil.ReadFile(filename)
|
||||
dataBytes, err = os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -204,7 +203,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
|
||||
}
|
||||
cdata.WriteString("0x00 };\n")
|
||||
|
||||
err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
err = os.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ package build
|
||||
|
||||
import (
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -52,7 +51,7 @@ func (d *DesktopBuilder) compileIcon(assetDir string, iconFile string) error {
|
||||
output = strings.Replace(output, "static char", "const char", 1)
|
||||
|
||||
// save icon.c
|
||||
err = ioutil.WriteFile(targetFile, []byte(output), 0755)
|
||||
err = os.WriteFile(targetFile, []byte(output), 0755)
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -2,12 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/leaanthony/slicer"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/leaanthony/slicer"
|
||||
)
|
||||
|
||||
func convertToHexLiteral(bytes []byte) string {
|
||||
@ -56,7 +57,7 @@ func buildMacIcons(dialogIconFilenames []string) error {
|
||||
for count, filename := range dialogIconFilenames {
|
||||
|
||||
// Load the tray icon
|
||||
dataBytes, err = ioutil.ReadFile(filename)
|
||||
dataBytes, err = os.ReadFile(filename)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -91,7 +92,7 @@ func buildMacIcons(dialogIconFilenames []string) error {
|
||||
}
|
||||
cdata.WriteString("0x00 };\n")
|
||||
|
||||
err = ioutil.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
err = os.WriteFile(targetFile, []byte(cdata.String()), 0600)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -73,7 +72,7 @@ func (s *ServerBuilder) BuildBaseAssets(assets *html.AssetBundle) error {
|
||||
|
||||
// Add wails.js
|
||||
wailsjsPath := fs.RelativePath("../../../internal/runtime/assets/server.js")
|
||||
if rawData, err := ioutil.ReadFile(wailsjsPath); err == nil {
|
||||
if rawData, err := os.ReadFile(wailsjsPath); err == nil {
|
||||
db.AddAsset("/wails.js", rawData)
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -44,7 +44,7 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package parser
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
@ -135,7 +134,7 @@ func generatePackage(pkg *Package, moduledir string) error {
|
||||
}
|
||||
|
||||
// Save typescript file
|
||||
err = ioutil.WriteFile(filepath.Join(moduledir, "_"+pkg.Name+".d.ts"), buffer.Bytes(), 0755)
|
||||
err = os.WriteFile(filepath.Join(moduledir, "_"+pkg.Name+".d.ts"), buffer.Bytes(), 0755)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error writing backend package file")
|
||||
}
|
||||
@ -156,7 +155,7 @@ func generatePackage(pkg *Package, moduledir string) error {
|
||||
}
|
||||
|
||||
// Save javascript file
|
||||
err = ioutil.WriteFile(filepath.Join(moduledir, "_"+pkg.Name+".js"), buffer.Bytes(), 0755)
|
||||
err = os.WriteFile(filepath.Join(moduledir, "_"+pkg.Name+".js"), buffer.Bytes(), 0755)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error writing backend package file")
|
||||
}
|
||||
@ -183,7 +182,7 @@ func generateIndexJS(dir string, packages []*Package) error {
|
||||
// Calculate target filename
|
||||
indexJS := filepath.Join(dir, "index.js")
|
||||
|
||||
err = ioutil.WriteFile(indexJS, buffer.Bytes(), 0755)
|
||||
err = os.WriteFile(indexJS, buffer.Bytes(), 0755)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error writing backend package index.js file")
|
||||
}
|
||||
@ -209,7 +208,7 @@ func generateIndexTS(dir string, packages []*Package) error {
|
||||
// Calculate target filename
|
||||
indexJS := filepath.Join(dir, "index.d.ts")
|
||||
|
||||
err = ioutil.WriteFile(indexJS, buffer.Bytes(), 0755)
|
||||
err = os.WriteFile(indexJS, buffer.Bytes(), 0755)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error writing backend package index.d.ts file")
|
||||
}
|
||||
@ -236,7 +235,7 @@ func generateGlobalsTS(dir string, packages []*Package) error {
|
||||
// Calculate target filename
|
||||
indexJS := filepath.Join(dir, "globals.d.ts")
|
||||
|
||||
err = ioutil.WriteFile(indexJS, buffer.Bytes(), 0755)
|
||||
err = os.WriteFile(indexJS, buffer.Bytes(), 0755)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error writing backend package globals.d.ts file")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user