Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: client/internal/common/json.go

Issue 2938823003: Move WriteJSONFile to its sole caller's package, with some refactoring. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/cmd/isolate/batch_archive.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/internal/common/json.go
diff --git a/client/internal/common/json.go b/client/internal/common/json.go
deleted file mode 100644
index d1b6c1ac424b99e7fdce3b11d9b2f911b1900e5b..0000000000000000000000000000000000000000
--- a/client/internal/common/json.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2015 The LUCI Authors. All rights reserved.
-// Use of this source code is governed under the Apache License, Version 2.0
-// that can be found in the LICENSE file.
-
-package common
-
-import (
- "encoding/json"
- "fmt"
- "os"
-)
-
-// WriteJSONFile writes object as json encoded into filePath with 2 spaces
-// indentation. File permission is set to user only.
-func WriteJSONFile(filePath string, object interface{}) error {
- d, err := json.MarshalIndent(object, "", " ")
- if err != nil {
- return fmt.Errorf("failed to encode %s: %s", filePath, err)
- }
-
- f, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
- if err != nil {
- return fmt.Errorf("failed to open %s: %s", filePath, err)
- }
- defer f.Close()
- if _, err := f.Write(d); err != nil {
- return fmt.Errorf("failed to write %s: %s", filePath, err)
- }
- return nil
-}
« no previous file with comments | « client/cmd/isolate/batch_archive.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698