2023-03-12 07:13:53 +03:00
|
|
|
// Package main is a command-lint tool `zs` called Zen Static for generating static websites
|
2014-12-05 19:59:56 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2023-03-12 07:13:53 +03:00
|
|
|
"context"
|
2014-12-05 19:59:56 +03:00
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
2015-09-02 18:00:14 +03:00
|
|
|
"os/exec"
|
2023-03-12 07:13:53 +03:00
|
|
|
"os/signal"
|
2014-12-05 19:59:56 +03:00
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
2023-03-12 07:13:53 +03:00
|
|
|
"syscall"
|
2015-08-29 19:46:05 +03:00
|
|
|
"text/template"
|
2014-12-05 19:59:56 +03:00
|
|
|
"time"
|
|
|
|
|
2021-09-18 02:12:48 +03:00
|
|
|
"github.com/russross/blackfriday/v2"
|
2023-03-12 07:13:53 +03:00
|
|
|
"go.mills.io/static"
|
2015-09-02 20:35:26 +03:00
|
|
|
"gopkg.in/yaml.v2"
|
2014-12-05 19:59:56 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2023-03-12 07:13:53 +03:00
|
|
|
// ZSDIR is the default directory for storing layouts and extensions
|
|
|
|
ZSDIR = ".zs"
|
|
|
|
|
|
|
|
// PUBDIR is the default directory for publishing final built content
|
2014-12-05 19:59:56 +03:00
|
|
|
PUBDIR = ".pub"
|
|
|
|
)
|
|
|
|
|
2023-03-12 07:13:53 +03:00
|
|
|
// Vars holds a map of global variables
|
2015-08-29 18:47:16 +03:00
|
|
|
type Vars map[string]string
|
2015-09-02 18:00:14 +03:00
|
|
|
|
2023-03-12 07:13:53 +03:00
|
|
|
// NewTicker is a function that wraps a time.Ticker and ticks immediately instead of waiting for the first interval
|
|
|
|
func NewTicker(d time.Duration) *time.Ticker {
|
|
|
|
ticker := time.NewTicker(d)
|
|
|
|
oc := ticker.C
|
|
|
|
nc := make(chan time.Time, 1)
|
|
|
|
go func() {
|
|
|
|
nc <- time.Now()
|
|
|
|
for tm := range oc {
|
|
|
|
nc <- tm
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ticker.C = nc
|
|
|
|
return ticker
|
|
|
|
}
|
|
|
|
|
2015-09-02 20:05:09 +03:00
|
|
|
// renameExt renames extension (if any) from oldext to newext
|
|
|
|
// If oldext is an empty string - extension is extracted automatically.
|
|
|
|
// If path has no extension - new extension is appended
|
|
|
|
func renameExt(path, oldext, newext string) string {
|
|
|
|
if oldext == "" {
|
|
|
|
oldext = filepath.Ext(path)
|
|
|
|
}
|
|
|
|
if oldext == "" || strings.HasSuffix(path, oldext) {
|
|
|
|
return strings.TrimSuffix(path, oldext) + newext
|
2015-09-02 18:00:14 +03:00
|
|
|
}
|
2021-10-28 19:10:15 +03:00
|
|
|
return path
|
2015-09-02 18:00:14 +03:00
|
|
|
}
|
|
|
|
|
2015-09-02 20:05:09 +03:00
|
|
|
// globals returns list of global OS environment variables that start
|
|
|
|
// with ZS_ prefix as Vars, so the values can be used inside templates
|
2015-09-02 18:00:14 +03:00
|
|
|
func globals() Vars {
|
|
|
|
vars := Vars{}
|
|
|
|
for _, e := range os.Environ() {
|
|
|
|
pair := strings.Split(e, "=")
|
|
|
|
if strings.HasPrefix(pair[0], "ZS_") {
|
|
|
|
vars[strings.ToLower(pair[0][3:])] = pair[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return vars
|
|
|
|
}
|
|
|
|
|
2015-09-02 20:05:09 +03:00
|
|
|
// run executes a command or a script. Vars define the command environment,
|
|
|
|
// each zs var is converted into OS environemnt variable with ZS_ prefix
|
|
|
|
// prepended. Additional variable $ZS contains path to the zs binary. Command
|
|
|
|
// stderr is printed to zs stderr, command output is returned as a string.
|
|
|
|
func run(vars Vars, cmd string, args ...string) (string, error) {
|
2021-09-18 02:32:14 +03:00
|
|
|
// First check if partial exists (.html)
|
2015-09-02 20:05:09 +03:00
|
|
|
if b, err := ioutil.ReadFile(filepath.Join(ZSDIR, cmd+".html")); err == nil {
|
|
|
|
return string(b), nil
|
2015-09-02 18:00:14 +03:00
|
|
|
}
|
|
|
|
|
2015-09-02 20:05:09 +03:00
|
|
|
var errbuf, outbuf bytes.Buffer
|
2015-09-02 18:00:14 +03:00
|
|
|
c := exec.Command(cmd, args...)
|
2015-09-02 20:05:09 +03:00
|
|
|
env := []string{"ZS=" + os.Args[0], "ZS_OUTDIR=" + PUBDIR}
|
|
|
|
env = append(env, os.Environ()...)
|
|
|
|
for k, v := range vars {
|
|
|
|
env = append(env, "ZS_"+strings.ToUpper(k)+"="+v)
|
|
|
|
}
|
|
|
|
c.Env = env
|
|
|
|
c.Stdout = &outbuf
|
2015-09-02 18:00:14 +03:00
|
|
|
c.Stderr = &errbuf
|
|
|
|
|
|
|
|
err := c.Run()
|
|
|
|
|
|
|
|
if errbuf.Len() > 0 {
|
|
|
|
log.Println("ERROR:", errbuf.String())
|
|
|
|
}
|
|
|
|
if err != nil {
|
2015-09-02 20:05:09 +03:00
|
|
|
return "", err
|
2015-09-02 18:00:14 +03:00
|
|
|
}
|
2015-09-02 20:05:09 +03:00
|
|
|
return string(outbuf.Bytes()), nil
|
2015-09-02 18:00:14 +03:00
|
|
|
}
|
2014-12-05 19:59:56 +03:00
|
|
|
|
2015-09-02 20:05:09 +03:00
|
|
|
// getVars returns list of variables defined in a text file and actual file
|
|
|
|
// content following the variables declaration. Header is separated from
|
|
|
|
// content by an empty line. Header can be either YAML or JSON.
|
|
|
|
// If no empty newline is found - file is treated as content-only.
|
|
|
|
func getVars(path string, globals Vars) (Vars, string, error) {
|
2015-08-29 18:47:16 +03:00
|
|
|
b, err := ioutil.ReadFile(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
}
|
|
|
|
s := string(b)
|
2015-09-02 20:05:09 +03:00
|
|
|
|
2015-09-02 20:43:31 +03:00
|
|
|
// Pick some default values for content-dependent variables
|
2015-09-02 20:05:09 +03:00
|
|
|
v := Vars{}
|
2015-09-02 20:43:31 +03:00
|
|
|
title := strings.Replace(strings.Replace(path, "_", " ", -1), "-", " ", -1)
|
|
|
|
v["title"] = strings.ToTitle(title)
|
|
|
|
v["description"] = ""
|
2015-09-04 15:49:56 +03:00
|
|
|
v["file"] = path
|
|
|
|
v["url"] = path[:len(path)-len(filepath.Ext(path))] + ".html"
|
|
|
|
v["output"] = filepath.Join(PUBDIR, v["url"])
|
2015-09-02 20:43:31 +03:00
|
|
|
|
2015-09-04 15:49:56 +03:00
|
|
|
// Override default values with globals
|
2015-08-30 17:01:05 +03:00
|
|
|
for name, value := range globals {
|
|
|
|
v[name] = value
|
2014-12-05 21:26:15 +03:00
|
|
|
}
|
2015-09-02 20:05:09 +03:00
|
|
|
|
2015-09-04 15:49:56 +03:00
|
|
|
// Add layout if none is specified
|
|
|
|
if _, ok := v["layout"]; !ok {
|
2021-09-18 02:32:14 +03:00
|
|
|
v["layout"] = "layout.html"
|
2015-08-30 00:43:59 +03:00
|
|
|
}
|
|
|
|
|
2015-09-02 20:35:26 +03:00
|
|
|
delim := "\n---\n"
|
2023-03-12 07:13:53 +03:00
|
|
|
sep := strings.Index(s, delim)
|
|
|
|
if sep == -1 {
|
2015-08-29 20:54:55 +03:00
|
|
|
return v, s, nil
|
2023-03-12 07:13:53 +03:00
|
|
|
}
|
2015-09-02 20:35:26 +03:00
|
|
|
|
2023-03-12 07:13:53 +03:00
|
|
|
header := s[:sep]
|
|
|
|
body := s[sep+len(delim):]
|
|
|
|
|
|
|
|
vars := Vars{}
|
|
|
|
if err := yaml.Unmarshal([]byte(header), &vars); err != nil {
|
|
|
|
fmt.Println("WARN: failed to parse header", err)
|
|
|
|
return v, s, nil
|
|
|
|
}
|
|
|
|
// Override default values + globals with the ones defines in the file
|
|
|
|
for key, value := range vars {
|
|
|
|
v[key] = value
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(v["url"], "./") {
|
|
|
|
v["url"] = v["url"][2:]
|
2014-12-05 20:09:10 +03:00
|
|
|
}
|
2023-03-12 07:13:53 +03:00
|
|
|
return v, body, nil
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
|
|
|
|
2015-09-02 20:05:09 +03:00
|
|
|
// Render expanding zs plugins and variables
|
2015-09-02 18:00:14 +03:00
|
|
|
func render(s string, vars Vars) (string, error) {
|
2023-03-12 07:13:53 +03:00
|
|
|
openingDelimiter := "{{"
|
|
|
|
closingDelimiter := "}}"
|
2015-09-02 20:05:09 +03:00
|
|
|
|
2015-08-29 19:46:05 +03:00
|
|
|
out := &bytes.Buffer{}
|
2015-09-02 20:05:09 +03:00
|
|
|
for {
|
2023-03-12 07:13:53 +03:00
|
|
|
from := strings.Index(s, openingDelimiter)
|
|
|
|
if from == -1 {
|
2015-09-02 20:05:09 +03:00
|
|
|
out.WriteString(s)
|
|
|
|
return out.String(), nil
|
2023-03-12 07:13:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
to := strings.Index(s, closingDelimiter)
|
|
|
|
if to == -1 {
|
|
|
|
return "", fmt.Errorf("Close delim not found")
|
|
|
|
}
|
|
|
|
|
|
|
|
out.WriteString(s[:from])
|
|
|
|
cmd := s[from+len(openingDelimiter) : to]
|
|
|
|
s = s[to+len(closingDelimiter):]
|
|
|
|
m := strings.Fields(cmd)
|
|
|
|
if len(m) == 1 {
|
|
|
|
if v, ok := vars[m[0]]; ok {
|
|
|
|
out.WriteString(v)
|
|
|
|
continue
|
2015-09-02 20:05:09 +03:00
|
|
|
}
|
|
|
|
}
|
2023-03-12 07:13:53 +03:00
|
|
|
if res, err := run(vars, m[0], m[1:]...); err == nil {
|
|
|
|
out.WriteString(res)
|
|
|
|
} else {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2015-08-29 19:46:05 +03:00
|
|
|
}
|
2022-08-14 03:52:15 +03:00
|
|
|
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
|
|
|
|
2015-08-29 19:46:05 +03:00
|
|
|
// Renders markdown with the given layout into html expanding all the macros
|
2015-09-02 18:00:14 +03:00
|
|
|
func buildMarkdown(path string, w io.Writer, vars Vars) error {
|
2015-09-02 20:05:09 +03:00
|
|
|
v, body, err := getVars(path, vars)
|
2014-12-05 19:59:56 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-09-02 18:00:14 +03:00
|
|
|
content, err := render(body, v)
|
2014-12-05 19:59:56 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-10-23 06:57:19 +03:00
|
|
|
v["content"] = string(blackfriday.Run(
|
|
|
|
[]byte(content),
|
|
|
|
blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs),
|
|
|
|
))
|
2015-08-30 15:20:35 +03:00
|
|
|
if w == nil {
|
|
|
|
out, err := os.Create(filepath.Join(PUBDIR, renameExt(path, "", ".html")))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer out.Close()
|
|
|
|
w = out
|
|
|
|
}
|
2021-09-18 02:32:14 +03:00
|
|
|
return buildHTML(filepath.Join(ZSDIR, v["layout"]), w, v)
|
2015-08-29 16:07:18 +03:00
|
|
|
}
|
|
|
|
|
2015-08-29 19:46:05 +03:00
|
|
|
// Renders text file expanding all variable macros inside it
|
2015-09-02 18:00:14 +03:00
|
|
|
func buildHTML(path string, w io.Writer, vars Vars) error {
|
2015-09-02 20:05:09 +03:00
|
|
|
v, body, err := getVars(path, vars)
|
2014-12-05 19:59:56 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-09-02 20:05:09 +03:00
|
|
|
if body, err = render(body, v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
tmpl, err := template.New("").Delims("<%", "%>").Parse(body)
|
2014-12-05 19:59:56 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-08-30 15:22:00 +03:00
|
|
|
if w == nil {
|
|
|
|
f, err := os.Create(filepath.Join(PUBDIR, path))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
w = f
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
2015-09-02 20:05:09 +03:00
|
|
|
return tmpl.Execute(w, vars)
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
|
|
|
|
2015-08-30 15:20:35 +03:00
|
|
|
// Copies file as is from path to writer
|
|
|
|
func buildRaw(path string, w io.Writer) error {
|
|
|
|
in, err := os.Open(path)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2015-08-29 20:54:55 +03:00
|
|
|
}
|
2015-08-30 15:20:35 +03:00
|
|
|
defer in.Close()
|
|
|
|
if w == nil {
|
2023-03-12 07:13:53 +03:00
|
|
|
out, err := os.Create(filepath.Join(PUBDIR, path))
|
|
|
|
if err != nil {
|
2015-08-30 15:20:35 +03:00
|
|
|
return err
|
2015-08-29 19:46:05 +03:00
|
|
|
}
|
2023-03-12 07:13:53 +03:00
|
|
|
defer out.Close()
|
|
|
|
w = out
|
2015-08-29 19:46:05 +03:00
|
|
|
}
|
2015-08-30 15:20:35 +03:00
|
|
|
_, err = io.Copy(w, in)
|
|
|
|
return err
|
2015-08-30 00:43:59 +03:00
|
|
|
}
|
|
|
|
|
2015-09-02 18:00:14 +03:00
|
|
|
func build(path string, w io.Writer, vars Vars) error {
|
2015-08-30 15:20:35 +03:00
|
|
|
ext := filepath.Ext(path)
|
|
|
|
if ext == ".md" || ext == ".mkd" {
|
2015-09-02 18:00:14 +03:00
|
|
|
return buildMarkdown(path, w, vars)
|
2015-08-30 15:20:35 +03:00
|
|
|
} else if ext == ".html" || ext == ".xml" {
|
2015-09-02 18:00:14 +03:00
|
|
|
return buildHTML(path, w, vars)
|
2015-08-30 15:20:35 +03:00
|
|
|
} else {
|
|
|
|
return buildRaw(path, w)
|
2015-08-29 19:46:05 +03:00
|
|
|
}
|
2015-08-29 20:54:55 +03:00
|
|
|
}
|
|
|
|
|
2023-03-12 07:13:53 +03:00
|
|
|
func buildAll(ctx context.Context, watch bool) {
|
|
|
|
ticker := NewTicker(time.Second)
|
|
|
|
defer ticker.Stop()
|
|
|
|
|
2015-08-29 20:54:55 +03:00
|
|
|
lastModified := time.Unix(0, 0)
|
|
|
|
modified := false
|
|
|
|
|
|
|
|
vars := globals()
|
2014-12-05 19:59:56 +03:00
|
|
|
for {
|
2023-03-12 07:13:53 +03:00
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
return
|
|
|
|
case <-ticker.C:
|
|
|
|
os.Mkdir(PUBDIR, 0755)
|
|
|
|
filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
|
|
|
|
// ignore hidden files and directories
|
|
|
|
if filepath.Base(path)[0] == '.' || strings.HasPrefix(path, ".") {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
// inform user about fs walk errors, but continue iteration
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("error:", err)
|
|
|
|
return nil
|
|
|
|
}
|
2014-12-05 19:59:56 +03:00
|
|
|
|
2023-03-12 07:13:53 +03:00
|
|
|
if info.IsDir() {
|
|
|
|
os.Mkdir(filepath.Join(PUBDIR, path), 0755)
|
|
|
|
return nil
|
|
|
|
} else if info.ModTime().After(lastModified) {
|
|
|
|
if !modified {
|
|
|
|
// First file in this build cycle is about to be modified
|
|
|
|
run(vars, "prehook")
|
|
|
|
modified = true
|
|
|
|
}
|
|
|
|
log.Println("build:", path)
|
|
|
|
return build(path, nil, vars)
|
2014-12-05 22:03:33 +03:00
|
|
|
}
|
2023-03-12 07:13:53 +03:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if modified {
|
|
|
|
// At least one file in this build cycle has been modified
|
|
|
|
run(vars, "posthook")
|
|
|
|
modified = false
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
2023-03-12 07:13:53 +03:00
|
|
|
if !watch {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
lastModified = time.Now()
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-12 07:13:53 +03:00
|
|
|
// serve runs a static web server and builds and continuously watches for changes to rebuild
|
|
|
|
func serve(ctx context.Context, bind string) error {
|
|
|
|
os.Mkdir(PUBDIR, 0755)
|
|
|
|
|
|
|
|
svr, err := static.NewServer(
|
|
|
|
static.WithBind(bind),
|
|
|
|
static.WithDir(true),
|
|
|
|
static.WithRoot(PUBDIR),
|
|
|
|
static.WithSPA(true),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
go svr.Run(ctx)
|
|
|
|
go buildAll(ctx, true)
|
|
|
|
|
|
|
|
<-ctx.Done()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-02 20:05:09 +03:00
|
|
|
func init() {
|
|
|
|
// prepend .zs to $PATH, so plugins will be found before OS commands
|
|
|
|
p := os.Getenv("PATH")
|
2022-08-14 03:52:15 +03:00
|
|
|
w, _ := os.Getwd()
|
|
|
|
p = filepath.Join(w, ZSDIR) + ":" + p
|
2015-09-02 20:05:09 +03:00
|
|
|
os.Setenv("PATH", p)
|
|
|
|
}
|
|
|
|
|
2014-12-05 19:59:56 +03:00
|
|
|
func main() {
|
|
|
|
if len(os.Args) == 1 {
|
2023-03-12 07:13:53 +03:00
|
|
|
fmt.Printf("%s <command> [args]\n", filepath.Base(os.Args[0]))
|
|
|
|
os.Exit(1)
|
2014-12-05 19:59:56 +03:00
|
|
|
return
|
|
|
|
}
|
2023-03-12 07:13:53 +03:00
|
|
|
|
2014-12-05 19:59:56 +03:00
|
|
|
cmd := os.Args[1]
|
|
|
|
args := os.Args[2:]
|
2023-03-12 07:13:53 +03:00
|
|
|
|
|
|
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
|
|
|
defer cancel()
|
|
|
|
|
2014-12-05 19:59:56 +03:00
|
|
|
switch cmd {
|
|
|
|
case "build":
|
2015-08-30 15:22:00 +03:00
|
|
|
if len(args) == 0 {
|
2023-03-12 07:13:53 +03:00
|
|
|
buildAll(ctx, false)
|
2015-08-30 15:22:00 +03:00
|
|
|
} else if len(args) == 1 {
|
2015-09-02 18:00:14 +03:00
|
|
|
if err := build(args[0], os.Stdout, globals()); err != nil {
|
2015-08-30 15:22:00 +03:00
|
|
|
fmt.Println("ERROR: " + err.Error())
|
|
|
|
}
|
2014-12-05 19:59:56 +03:00
|
|
|
} else {
|
2015-08-30 15:22:00 +03:00
|
|
|
fmt.Println("ERROR: too many arguments")
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
2015-08-30 15:22:00 +03:00
|
|
|
case "watch":
|
2023-03-12 07:13:53 +03:00
|
|
|
buildAll(ctx, true)
|
|
|
|
case "serve":
|
|
|
|
bind := ":8000"
|
|
|
|
if len(args) > 1 {
|
|
|
|
bind = args[0]
|
|
|
|
}
|
|
|
|
if err := serve(ctx, bind); err != nil {
|
|
|
|
fmt.Println("ERROR: " + err.Error())
|
|
|
|
}
|
2015-08-30 15:20:35 +03:00
|
|
|
case "var":
|
2015-09-02 18:00:14 +03:00
|
|
|
if len(args) == 0 {
|
|
|
|
fmt.Println("var: filename expected")
|
|
|
|
} else {
|
|
|
|
s := ""
|
2015-09-04 15:49:56 +03:00
|
|
|
if vars, _, err := getVars(args[0], Vars{}); err != nil {
|
2015-09-02 18:00:14 +03:00
|
|
|
fmt.Println("var: " + err.Error())
|
|
|
|
} else {
|
|
|
|
if len(args) > 1 {
|
|
|
|
for _, a := range args[1:] {
|
|
|
|
s = s + vars[a] + "\n"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for k, v := range vars {
|
|
|
|
s = s + k + ":" + v + "\n"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Println(strings.TrimSpace(s))
|
|
|
|
}
|
2014-12-05 19:59:56 +03:00
|
|
|
default:
|
2015-09-02 20:05:09 +03:00
|
|
|
if s, err := run(globals(), cmd, args...); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
} else {
|
|
|
|
fmt.Println(s)
|
2014-12-05 19:59:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|