aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-04-29 21:19:14 +0200
committerStefan Majewsky <majewsky@gmx.net>2018-04-30 10:04:36 +0200
commit0df55a731aa3330f82d22b010a7a2a4d66521972 (patch)
tree9e207f01dbb52afb0de83f95e63ecfc771e809c6 /util
parent1f3fcfa9366e49b371c7be2b5c90b957ce93b8dd (diff)
downloadgo-schwift-0df55a731aa3330f82d22b010a7a2a4d66521972.tar.gz
initial support for large objects
This has gone through a lot of iterations on my branch, and I'm quite happy with the parts of the API that exist now. Test coverage can still be better, and will get better in the following commits. The API is not yet finished: I want to add Options arguments to Object.Upload(), Object.Copy(), Object.Move() and Object.Delete() that specify how each of these operations affect existing segments (and, later, also existing symlinks). For Upload(), uploading in segments shall become as easy as flipping a single switch.
Diffstat (limited to 'util')
-rwxr-xr-xutil/gocovcat.go87
1 files changed, 87 insertions, 0 deletions
diff --git a/util/gocovcat.go b/util/gocovcat.go
new file mode 100755
index 0000000..bb03f87
--- /dev/null
+++ b/util/gocovcat.go
@@ -0,0 +1,87 @@
+///usr/bin/env go run "$0" "$@"; exit $?
+
+// Copyright 2017 Luke Shumaker <lukeshu@parabola.nu>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+// Command gocovcat combines multiple go cover runs, and prints the
+// result on stdout.
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "sort"
+ "strconv"
+ "strings"
+)
+
+func handleErr(err error) {
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "%v\n", err)
+ os.Exit(1)
+ }
+}
+
+func main() {
+ modeBool := false
+ blocks := map[string]int{}
+ for _, filename := range os.Args[1:] {
+ file, err := os.Open(filename)
+ handleErr(err)
+ buf := bufio.NewScanner(file)
+ for buf.Scan() {
+ line := buf.Text()
+
+ if strings.HasPrefix(line, "mode: ") {
+ m := strings.TrimPrefix(line, "mode: ")
+ switch m {
+ case "set":
+ modeBool = true
+ case "count", "atomic":
+ // do nothing
+ default:
+ fmt.Fprintf(os.Stderr, "Unrecognized mode: %s\n", m)
+ os.Exit(1)
+ }
+ } else {
+ sp := strings.LastIndexByte(line, ' ')
+ block := line[:sp]
+ cntStr := line[sp+1:]
+ cnt, err := strconv.Atoi(cntStr)
+ handleErr(err)
+ blocks[block] += cnt
+ }
+ }
+ handleErr(buf.Err())
+ }
+ keys := make([]string, 0, len(blocks))
+ for key := range blocks {
+ keys = append(keys, key)
+ }
+ sort.Strings(keys)
+ modeStr := "count"
+ if modeBool {
+ modeStr = "set"
+ }
+ fmt.Printf("mode: %s\n", modeStr)
+ for _, block := range keys {
+ cnt := blocks[block]
+ if modeBool && cnt > 1 {
+ cnt = 1
+ }
+ fmt.Printf("%s %d\n", block, cnt)
+ }
+}