modernc.org/z@v1.7.4/z.go (about)

     1  // Copyright 2021 The Zlib-Go Authors. All rights reserved.
     2  // Use of the source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:generate go run generator.go
     6  
     7  // Package z implements the native Go API for zlib.
     8  //
     9  // The API si currently empty.
    10  //
    11  // zlib 1.2.11 is a general purpose data compression library.  All the code is
    12  // thread safe.  The data format used by the zlib library is described by RFCs
    13  // (Request for Comments) 1950 to 1952 in the files
    14  // http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
    15  // rfc1952 (gzip format).
    16  //
    17  // Installation
    18  //
    19  //	$ go get modernc.org/z
    20  //
    21  // Linking using ccgo
    22  //
    23  //	$ ccgo foo.c -lmodernc.org/z/lib
    24  //
    25  // Documentation
    26  //
    27  //	http://godoc.org/modernc.org/z
    28  //
    29  // Builders
    30  //
    31  //	https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fz
    32  package z // import "modernc.org/z"
    33  
    34  import (
    35  	"fmt"
    36  	"os"
    37  	"runtime"
    38  	"strings"
    39  )
    40  
    41  func origin(skip int) string {
    42  	pc, fn, fl, _ := runtime.Caller(skip)
    43  	f := runtime.FuncForPC(pc)
    44  	var fns string
    45  	if f != nil {
    46  		fns = f.Name()
    47  		if x := strings.LastIndex(fns, "."); x > 0 {
    48  			fns = fns[x+1:]
    49  		}
    50  	}
    51  	return fmt.Sprintf("%s:%d:%s", fn, fl, fns)
    52  }
    53  
    54  func todo(s string, args ...interface{}) string {
    55  	switch {
    56  	case s == "":
    57  		s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
    58  	default:
    59  		s = fmt.Sprintf(s, args...)
    60  	}
    61  	r := fmt.Sprintf("%s: TODO %s", origin(2), s) //TODOOK
    62  	fmt.Fprintf(os.Stdout, "%s\n", r)
    63  	os.Stdout.Sync()
    64  	return r
    65  }
    66  
    67  func trc(s string, args ...interface{}) string {
    68  	switch {
    69  	case s == "":
    70  		s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
    71  	default:
    72  		s = fmt.Sprintf(s, args...)
    73  	}
    74  	r := fmt.Sprintf("%s: TRC %s", origin(2), s)
    75  	fmt.Fprintf(os.Stdout, "%s\n", r)
    76  	os.Stdout.Sync()
    77  	return r
    78  }