• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang pretty.Formatter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/kr/pretty.Formatter函数的典型用法代码示例。如果您正苦于以下问题:Golang Formatter函数的具体用法?Golang Formatter怎么用?Golang Formatter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Formatter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: MustNewWinPdhCollector

func MustNewWinPdhCollector(name, prefix string, opts config.Config_win_pdh_collector) *win_pdh_collector {

	c := &win_pdh_collector{
		name:        name,
		enabled:     true,
		prefix:      prefix,
		interval:    opts.Interval.MustDuration(time.Second),
		config:      opts,
		hPdh:        pdh.NewPdhCollector(),
		map_queries: make(map[string]config.Config_win_pdh_query),
	}

	for _, q := range opts.Queries {
		if q.Metric == "" {
			logging.Errorf("Error Phd Collector metric is empty: %# v", pretty.Formatter(q))
			continue
		}

		c.hPdh.AddEnglishCounter(q.Query)
		if q.Tags == nil {
			q.Tags = newcore.AddTags.Copy()
		}

		if opts.Query_to_tag == true || q.Query_to_tag == true {
			q.Tags["query"] = q.Query
		}

		c.map_queries[q.Query] = q
	}
	logging.Tracef("MustNewWinPdhCollector:opts.Queries: %# v", pretty.Formatter(opts.Queries))
	logging.Tracef("MustNuewWinPdhCollector c.map_queries: %# v", pretty.Formatter(c.map_queries))
	return c
}
开发者ID:homingway,项目名称:hickwall,代码行数:33,代码来源:pdh_windows.go


示例2: TestGetChart

func TestGetChart(t *testing.T) {
	server, zillow := testFixtures(t, chartPath, func(values url.Values) {
		assertOnlyParam(t, values, zpidParam, zpid)
		assertOnlyParam(t, values, unitTypeParam, unitType)
		assertOnlyParam(t, values, widthParam, strconv.Itoa(width))
		assertOnlyParam(t, values, heightParam, strconv.Itoa(height))
	})
	defer server.Close()

	request := ChartRequest{Zpid: zpid, UnitType: unitType, Width: width, Height: height}
	result, err := zillow.GetChart(request)
	if err != nil {
		t.Fatal(err)
	}
	expected := &ChartResult{
		XMLName: xml.Name{Space: "http://www.zillowstatic.com/vstatic/8d9b5f1/static/xsd/Chart.xsd", Local: "chart"},
		Request: request,
		Message: Message{
			Text: "Request successfully processed",
			Code: 0,
		},
		Url: "http://www.zillow.com/app?chartDuration=1year&chartType=partner&height=150&page=webservice%2FGetChart&service=chart&showPercent=true&width=300&zpid=48749425",
	}

	if !reflect.DeepEqual(result, expected) {
		t.Fatalf("expected:\n %#v\n\n but got:\n %#v\n\n diff:\n %s\n",
			pretty.Formatter(expected), pretty.Formatter(result), pretty.Diff(expected, result))
	}
}
开发者ID:jmank88,项目名称:zillow,代码行数:29,代码来源:zillow_test.go


示例3: TestCopy_MakeTarStream_SingleFileToDir

func TestCopy_MakeTarStream_SingleFileToDir(t *testing.T) {
	tmpDir := makeTmpDir(t, map[string]string{
		"foo.txt": "hello",
	})
	defer os.RemoveAll(tmpDir)

	assertions := [][3]string{
		{"foo.txt", "foo", "foo"},
		{"foo.txt", "foo/", "foo/foo.txt"},
	}

	for _, a := range assertions {
		includes := []string{a[0]}
		excludes := []string{}
		dest := a[1]

		t.Logf("includes: %# v", pretty.Formatter(includes))
		t.Logf("excludes: %# v", pretty.Formatter(excludes))
		t.Logf("dest: %# v", pretty.Formatter(dest))

		stream, err := makeTarStream(tmpDir, dest, "COPY", includes, excludes, nil)
		if err != nil {
			t.Fatal(err)
		}

		out := writeReadTar(t, tmpDir, stream.tar)

		assertion := strings.Join([]string{a[2]}, "\n") + "\n"

		assert.Equal(t, assertion, out, "bad tar content for COPY %s %s", a[0], a[1])
	}
}
开发者ID:andrewrothstein,项目名称:rocker,代码行数:32,代码来源:copy_test.go


示例4: main

func main() {
	r := Rocket{
		name:         "Audrey Mark 0",
		mass:         Measurement{value: 0.05, units: "kg"},
		area:         Measurement{value: 0.0004, units: "m^2"},
		drag:         Measurement{value: 0.75, units: ""}, //seems reasonable
		max_velocity: Measurement{value: 0, units: "m/s"},
		max_altitude: Measurement{value: 0, units: "m"},
		//https://en.wikipedia.org/wiki/Drag_coefficient

	} //estimated rocket

	e := Engine{
		product_number:  1598,
		name:            "A8-3",
		max_payload:     Measurement{value: 0.085, units: "kg"},
		delay:           Measurement{value: 3, units: "s"},
		impulse:         Measurement{value: 2.5, units: "N-s"},
		thrust:          Measurement{value: 10.7, units: "N"},
		mass:            Measurement{value: 0.0162, units: "kg"},
		propellant_mass: Measurement{value: 0.00312, units: "kg"},
		burn_time:       Measurement{value: 0.5, units: "s"},
	} //example for A8-3

	compute_terminal_conditons(&r, &e)
	fmt.Printf("%# v\n", pretty.Formatter(r))
	fmt.Printf("%# v\n", pretty.Formatter(e))

	fmt.Printf("You're going to reach %v maximum velocity\n", r.max_velocity)
	fmt.Println("Your maximum altitude will be:", r.max_altitude)

}
开发者ID:dfiru,项目名称:firutils,代码行数:32,代码来源:rocket.go


示例5: TestCopy_ListFiles_Dir_Simple

func TestCopy_ListFiles_Dir_Simple(t *testing.T) {
	tmpDir := makeTmpDir(t, map[string]string{
		"dir/foo.txt": "hello",
		"dir/bar.txt": "hello",
	})
	defer os.RemoveAll(tmpDir)

	includes := []string{
		"dir",
	}
	excludes := []string{}

	matches, err := listFiles(tmpDir, includes, excludes, "COPY", nil)
	if err != nil {
		t.Fatal(err)
	}

	t.Logf("includes: %# v", pretty.Formatter(includes))
	t.Logf("excludes: %# v", pretty.Formatter(excludes))
	t.Logf("matches: %# v", pretty.Formatter(matches))

	assertions := [][2]string{
		{tmpDir + "/dir/bar.txt", "dir/bar.txt"},
		{tmpDir + "/dir/foo.txt", "dir/foo.txt"},
	}

	assert.Len(t, matches, len(assertions))
	for i, a := range assertions {
		assert.Equal(t, a[0], matches[i].src, "bad match src at index %d", i)
		assert.Equal(t, a[1], matches[i].dest, "bad match dest at index %d", i)
	}
}
开发者ID:andrewrothstein,项目名称:rocker,代码行数:32,代码来源:copy_test.go


示例6: TestCopy_MakeTarStream_SingleFileDirRename

func TestCopy_MakeTarStream_SingleFileDirRename(t *testing.T) {
	tmpDir := makeTmpDir(t, map[string]string{
		"c/foo.txt": "hello",
	})
	defer os.RemoveAll(tmpDir)

	// ADD ./c /src --> /src
	// ADD ./a/b[/1,2] /src -> /src[/1,2]

	includes := []string{
		"./c",
	}
	excludes := []string{}
	dest := "/src"

	t.Logf("includes: %# v", pretty.Formatter(includes))
	t.Logf("excludes: %# v", pretty.Formatter(excludes))
	t.Logf("dest: %# v", pretty.Formatter(dest))

	stream, err := makeTarStream(tmpDir, dest, "COPY", includes, excludes, nil)
	if err != nil {
		t.Fatal(err)
	}

	out := writeReadTar(t, tmpDir, stream.tar)

	assertion := strings.Join([]string{
		"src/foo.txt",
	}, "\n") + "\n"

	assert.Equal(t, assertion, out, "bad tar content")
}
开发者ID:andrewrothstein,项目名称:rocker,代码行数:32,代码来源:copy_test.go


示例7: TestSNSMessageNotFound

func TestSNSMessageNotFound(t *testing.T) {
	server := server.MockDBServer()
	defer server.Close()

	snsString := fmt.Sprintf(`{
		"Type" : "Notification",
		"MessageId" : "12",
		"TopicArn" : "arn",
		"Subject" : "Amazon S3 Notification",
		"Message" : "{\"Records\":[{\"s3\":{\"bucket\":{\"name\":\"sc-gallery\"},\"object\":{\"key\":\"%v\",\"size\":71501}}}]}",
		"Timestamp" : "2015-04-14T03:48:23.584Z",
		"SignatureVersion" : "1",
		"Signature" : "liP1M"
	}`, "original_file/134444")

	req := tests.MockRequest{}
	req.Url = "/notify/sns/"
	req.Method = "post"
	req.Data = map[string]interface{}{}
	utils.Decoder([]byte(snsString), &req.Data)

	server.Test(&req, func(msg *tests.MockResponse) {
		exception := "This message should be ignored."
		if msg.Status != 200 {
			fmt.Printf("%# v", pretty.Formatter(msg))
			t.Error(exception)
		}

		if msg.Message != "" {
			fmt.Printf("%# v", pretty.Formatter(msg))
			t.Error(exception)
		}
	})
}
开发者ID:josjevv,项目名称:moire,代码行数:34,代码来源:pdf_flow_test.go


示例8: TestCreatePDFCollection

func TestCreatePDFCollection(t *testing.T) {
	server := server.MockDBServer()
	defer server.Close()

	req := tests.MockRequest{}
	req.Url = "/assets"
	req.Method = "post"
	req.Data = map[string]interface{}{
		"mime_type":  "application/pdf",
		"name":       randSeq(10),
		"collection": randSeq(5),
	}

	server.Test(&req, func(msg *tests.MockResponse) {
		utils.Convert(&msg.Data, &assetRet)

		if msg.Status != 200 {
			fmt.Printf("%# v", pretty.Formatter(msg))
			t.Error("Asset creation should return status 200.")
		}

		for _, key := range []string{"upload_url", "url", "_id"} {
			if val, ok := assetRet[key]; !ok || len(val) == 0 {
				fmt.Printf("%# v", pretty.Formatter(msg))
				t.Error(key + " should be a valid string in creation return.")
			}
		}
	})
}
开发者ID:josjevv,项目名称:moire,代码行数:29,代码来源:collection_test.go


示例9: TestCopy_MakeTarStream_SubDirRenameWildcard

func TestCopy_MakeTarStream_SubDirRenameWildcard(t *testing.T) {
	tmpDir := makeTmpDir(t, map[string]string{
		"a/c/foo.txt": "hello",
		"a/c/x/1.txt": "hello",
		"a/c/x/2.txt": "hello",
	})
	defer os.RemoveAll(tmpDir)

	includes := []string{
		"a/*",
	}
	excludes := []string{}
	dest := "/src"

	t.Logf("includes: %# v", pretty.Formatter(includes))
	t.Logf("excludes: %# v", pretty.Formatter(excludes))
	t.Logf("dest: %# v", pretty.Formatter(dest))

	stream, err := makeTarStream(tmpDir, dest, "COPY", includes, excludes)
	if err != nil {
		t.Fatal(err)
	}

	out := writeReadTar(t, tmpDir, stream.tar)

	assertion := strings.Join([]string{
		"src/c/foo.txt",
		"src/c/x/1.txt",
		"src/c/x/2.txt",
	}, "\n") + "\n"

	assert.Equal(t, assertion, out, "bad tar content")
}
开发者ID:romank87,项目名称:rocker,代码行数:33,代码来源:copy_test.go


示例10: TestSNSMessageIgnoredPath

func TestSNSMessageIgnoredPath(t *testing.T) {
	server := server.MockDBServer()
	defer server.Close()

	snsString := fmt.Sprintf(`{
		"Type" : "Notification",
		"MessageId" : "12",
		"TopicArn" : "arn",
		"Subject" : "Amazon S3 Notification",
		"Message" : "{\"Records\":[{\"s3\":{\"bucket\":{\"name\":\"sc-gallery\"},\"object\":{\"key\":\"%v\",\"size\":71501}}}]}",
		"Timestamp" : "2015-04-14T03:48:23.584Z",
		"SignatureVersion" : "1",
		"Signature" : "liP1M"
	}`, "/hello/world/")

	req := tests.MockRequest{}
	req.Url = "/notify/sns/"
	req.Method = "post"
	req.Data = map[string]interface{}{}
	utils.Decoder([]byte(snsString), &req.Data)

	server.Test(&req, func(msg *tests.MockResponse) {
		exception := "This path should have been ignroed."

		if msg.Status != 400 {
			fmt.Printf("%# v", pretty.Formatter(msg))
			t.Error(exception)
		}

		if !strings.Contains(msg.Message, "not meant to be monitored") {
			fmt.Printf("%# v", pretty.Formatter(msg))
			t.Error(exception)
		}
	})
}
开发者ID:josjevv,项目名称:moire,代码行数:35,代码来源:pdf_flow_test.go


示例11: TestCopy_ListFiles_Excludes_FileInAnyDir

func TestCopy_ListFiles_Excludes_FileInAnyDir(t *testing.T) {
	tmpDir := makeTmpDir(t, map[string]string{
		"a/test1.txt":     "hello",
		"b/test2.txt":     "hello",
		"c/d/e/test2.txt": "hello",
	})
	defer os.RemoveAll(tmpDir)

	includes := []string{
		".",
	}
	excludes := []string{
		"**/test2.txt",
	}

	matches, err := listFiles(tmpDir, includes, excludes)
	if err != nil {
		t.Fatal(err)
	}

	t.Logf("includes: %# v", pretty.Formatter(includes))
	t.Logf("excludes: %# v", pretty.Formatter(excludes))
	t.Logf("matches: %# v", pretty.Formatter(matches))

	assertions := [][2]string{
		{tmpDir + "/a/test1.txt", "a/test1.txt"},
	}

	assert.Len(t, matches, len(assertions))
	for i, a := range assertions {
		assert.Equal(t, a[0], matches[i].src, "bad match src at index %d", i)
		assert.Equal(t, a[1], matches[i].dest, "bad match dest at index %d", i)
	}
}
开发者ID:romank87,项目名称:rocker,代码行数:34,代码来源:copy_test.go


示例12: ExampleProxy

// ExampleProxy shows a chain of servers and clients.
func ExampleProxy() {
	log.Println("\n***** ExampleProxy *****\n")

	// Real
	var realServer = offers.MustNewServer(configure("Real Server"), offers.Offers{Configuration: configure("Server")}, ":4030") // Use s as the service.
	go func() {
		if err := realServer.Start(); err != nil {
			panic(err)
		}
	}()
	var realClient = offers.MustNewClient(configure("Real Client"), ":4030")

	// Proxy
	var proxyServer = offers.MustNewServer(configure("Proxy Server"), realClient, ":4031") // Use realClient as the service.
	go func() {
		if err := proxyServer.Start(); err != nil {
			panic(err)
		}
	}()
	var proxyClient = offers.MustNewClient(configure("Proxy Client"), ":4031").ForContext(offers.Context{ID: tigertonic.RandomBase62String(8)}).(offers.Client)

	// Use
	m, err := proxyClient.New(offer.Offer{Name: "nerddomo"})
	if err != nil {
		panic(err)
	}
	log.Printf("New: Got: %# v\n\n", pretty.Formatter(simplify(m)))
	m, err = proxyClient.Get(m.ID)
	if err != nil {
		panic(err)
	}
	log.Printf("Get: Got: %# v\n\n", pretty.Formatter(simplify(m)))
	m.Name = "test"
	m, err = proxyClient.Set(m)
	if err != nil {
		panic(err)
	}
	log.Printf("Set: Got: %# v\n\n", pretty.Formatter(simplify(m)))
	m, err = proxyClient.Delete(m)
	if err != nil {
		panic(err)
	}
	log.Printf("Delete: Got: %# v\n\n", pretty.Formatter(simplify(m)))

	// Proxy
	if err := proxyClient.Close(); err != nil {
		panic(err)
	}
	if err := proxyServer.Stop(); err != nil {
		panic(err)
	}

	// Real
	if err := realClient.Close(); err != nil {
		panic(err)
	}
	if err := realServer.Stop(); err != nil {
		panic(err)
	}
}
开发者ID:willfaught,项目名称:services,代码行数:61,代码来源:main.go


示例13: TestGetRateSummary

func TestGetRateSummary(t *testing.T) {
	server, zillow := testFixtures(t, rateSummaryPath, func(values url.Values) {
		assertOnlyParam(t, values, stateParam, state)
	})
	defer server.Close()

	request := RateSummaryRequest{State: state}
	result, err := zillow.GetRateSummary(request)
	if err != nil {
		t.Fatal(err)
	}
	expected := &RateSummary{
		XMLName: xml.Name{Space: "http://www.zillow.com/static/xsd/RateSummary.xsd", Local: "rateSummary"},
		Message: Message{
			Text: "Request successfully processed",
			Code: 0,
		},
		Today: []Rate{
			Rate{LoanType: "thirtyYearFixed", Count: 1252, Value: 5.91},
			Rate{LoanType: "fifteenYearFixed", Count: 839, Value: 5.68},
			Rate{LoanType: "fiveOneARM", Count: 685, Value: 5.49},
		},
		LastWeek: []Rate{
			Rate{LoanType: "thirtyYearFixed", Count: 8933, Value: 6.02},
			Rate{LoanType: "fifteenYearFixed", Count: 5801, Value: 5.94},
			Rate{LoanType: "fiveOneARM", Count: 3148, Value: 5.71},
		},
	}

	if !reflect.DeepEqual(result, expected) {
		t.Fatalf("expected:\n %#v\n\n but got:\n %#v\n\n diff:\n %s\n",
			pretty.Formatter(expected), pretty.Formatter(result), pretty.Diff(expected, result))
	}
}
开发者ID:jmank88,项目名称:zillow,代码行数:34,代码来源:zillow_test.go


示例14: TestCopy_MakeTarStream_WierdWildcards

func TestCopy_MakeTarStream_WierdWildcards(t *testing.T) {
	tmpDir := makeTmpDir(t, map[string]string{
		"abc.txt": "hello",
		"adf.txt": "hello",
		"bvz.txt": "hello",
	})
	defer os.RemoveAll(tmpDir)

	includes := []string{
		"a*.txt",
	}
	excludes := []string{}
	dest := "./"

	t.Logf("includes: %# v", pretty.Formatter(includes))
	t.Logf("excludes: %# v", pretty.Formatter(excludes))
	t.Logf("dest: %# v", pretty.Formatter(dest))

	stream, err := makeTarStream(tmpDir, dest, "COPY", includes, excludes, nil)
	if err != nil {
		t.Fatal(err)
	}

	out := writeReadTar(t, tmpDir, stream.tar)

	assertion := strings.Join([]string{
		"./abc.txt",
		"./adf.txt",
	}, "\n") + "\n"

	assert.Equal(t, assertion, out, "bad tar content")
}
开发者ID:andrewrothstein,项目名称:rocker,代码行数:32,代码来源:copy_test.go


示例15: main

func main() {
	var (
		mongoSession *mgo.Session
		database     *mgo.Database
		collection   *mgo.Collection
		changeInfo   *mgo.ChangeInfo
		err          error
	)

	if mongoSession, err = mgo.Dial("localhost"); err != nil {
		panic(err)
	}

	database = mongoSession.DB("mgo_examples_03")
	collection = database.C("todos")

	// START OMIT
	var todo = Todo{
		Id:      bson.NewObjectId(),
		Task:    "Demo mgo",
		Created: time.Now(),
	}

	// This is a shortcut to collection.Upsert(bson.M{"_id": todo.id}, &todo)
	if changeInfo, err = collection.UpsertId(todo.Id, &todo); err != nil {
		panic(err)
	}
	// END OMIT

	fmt.Printf("Todo: %# v", pretty.Formatter(todo))
	fmt.Printf("Change Info: %# v", pretty.Formatter(changeInfo))

}
开发者ID:johnzan,项目名称:talks,代码行数:33,代码来源:main.go


示例16: TestConnGrant

func TestConnGrant(t *testing.T) {
	for _, tst := range grantTests {
		ok := tst.c.grant(tst.sk)
		assert.Equalf(t, tst.ok, ok, "%# v", pretty.Formatter(tst))
		assert.Equalf(t, tst.r, tst.c.raccess, "%# v", pretty.Formatter(tst))
		assert.Equalf(t, tst.w, tst.c.waccess, "%# v", pretty.Formatter(tst))
	}
}
开发者ID:zyxar,项目名称:doozerd,代码行数:8,代码来源:conn_test.go


示例17: TestCopy_MakeTarStream_DirRenameDestLeadingSlash

func TestCopy_MakeTarStream_DirRenameDestLeadingSlash(t *testing.T) {
	tmpDir := makeTmpDir(t, map[string]string{
		"lib/foo.txt": "hello",
		"lib/x/1.txt": "hello",
		"lib/x/2.txt": "hello",
	})
	defer os.RemoveAll(tmpDir)

	// WORKDIR /app
	// COPY lib lib
	// COPY lib lib/
	// COPY lib/ lib
	// COPY lib/ lib/
	// /app
	// /app/lib
	// /app/lib/foo.txt
	// /app/lib/x/1.txt
	// /app/lib/x/2.txt

	assertions := [][2]string{
		{"lib", "lib"},
		{"lib", "lib/"},
		{"lib/", "lib"},
		{"lib/", "lib/"},
	}

	for _, a := range assertions {
		includes := []string{a[0]}
		excludes := []string{}
		dest := a[1]

		t.Logf("includes: %# v", pretty.Formatter(includes))
		t.Logf("excludes: %# v", pretty.Formatter(excludes))
		t.Logf("dest: %# v", pretty.Formatter(dest))

		stream, err := makeTarStream(tmpDir, dest, "COPY", includes, excludes, nil)
		if err != nil {
			t.Fatal(err)
		}

		out := writeReadTar(t, tmpDir, stream.tar)

		assertion := strings.Join([]string{
			"lib/foo.txt",
			"lib/x/1.txt",
			"lib/x/2.txt",
		}, "\n") + "\n"

		assert.Equal(t, assertion, out, "bad tar content for COPY %s %s", a[0], a[1])
	}
}
开发者ID:andrewrothstein,项目名称:rocker,代码行数:51,代码来源:copy_test.go


示例18: TestGetMonthlyPayments

func TestGetMonthlyPayments(t *testing.T) {
	server, zillow := testFixtures(t, monthlyPaymentsPath, func(values url.Values) {
		assertOnlyParam(t, values, priceParam, strconv.Itoa(price))
		assertOnlyParam(t, values, downParam, strconv.Itoa(down))
		assertOnlyParam(t, values, zipParam, zip)
	})
	defer server.Close()

	request := MonthlyPaymentsRequest{Price: price, Down: down, Zip: zip}
	result, err := zillow.GetMonthlyPayments(request)
	if err != nil {
		t.Fatal(err)
	}
	expected := &MonthlyPayments{
		XMLName: xml.Name{Space: "http://www.zillow.com/static/xsd/MonthlyPayments.xsd", Local: "paymentsSummary"},
		Request: request,
		Message: Message{
			Text: "Request successfully processed",
			Code: 0,
		},
		Payments: []Payment{
			{
				LoanType: "thirtyYearFixed",
				Rate:     5.9,
				MonthlyPrincipalAndInterest: 1512,
				MonthlyMortgageInsurance:    68,
			},
			{
				LoanType: "fifteenYearFixed",
				Rate:     5.68,
				MonthlyPrincipalAndInterest: 1477,
				MonthlyMortgageInsurance:    68,
			},
			{
				LoanType: "fiveOneARM",
				Rate:     5.71,
				MonthlyPrincipalAndInterest: 1482,
				MonthlyMortgageInsurance:    74,
			},
		},
		DownPayment:            45000,
		MonthlyPropertyTaxes:   193,
		MonthlyHazardInsurance: 49,
	}

	if !reflect.DeepEqual(result, expected) {
		t.Fatalf("expected:\n %#v\n\n but got:\n %#v\n\n diff:\n %s\n",
			pretty.Formatter(expected), pretty.Formatter(result), pretty.Diff(expected, result))
	}
}
开发者ID:jmank88,项目名称:zillow,代码行数:50,代码来源:zillow_test.go


示例19: Run

// Run runs the build following the given Plan
func (b *Build) Run(plan Plan) (err error) {

	for k := 0; k < len(plan); k++ {
		c := plan[k]

		log.Debugf("Step %d: %# v", k+1, pretty.Formatter(c))

		var doRun bool
		if doRun, err = c.ShouldRun(b); err != nil {
			return err
		}
		if !doRun {
			continue
		}

		// Replace env for the command if appropriate
		if c, ok := c.(EnvReplacableCommand); ok {
			c.ReplaceEnv(b.state.Config.Env)
		}

		log.Infof("%s", color.New(color.FgWhite, color.Bold).SprintFunc()(c))

		if b.state, err = c.Execute(b); err != nil {
			return err
		}

		log.Debugf("State after step %d: %# v", k+1, pretty.Formatter(b.state))

		// Here we need to inject ONBUILD commands on the fly,
		// build sub plan and merge it with the main plan.
		// Not very beautiful, because Run uses Plan as the argument
		// and then it builds its own. But.
		if len(b.state.InjectCommands) > 0 {
			commands, err := parseOnbuildCommands(b.state.InjectCommands)
			if err != nil {
				return err
			}
			subPlan, err := NewPlan(commands, false)
			if err != nil {
				return err
			}
			tail := append(subPlan, plan[k+1:]...)
			plan = append(plan[:k+1], tail...)

			b.state.InjectCommands = []string{}
		}
	}

	return nil
}
开发者ID:romank87,项目名称:rocker,代码行数:51,代码来源:build.go


示例20: ExampleMethod

// ExampleMethod shows using a method.
func ExampleMethod() {
	log.Println("\n***** ExampleMethod *****\n")

	// Server
	var server = offers.MustNewServer(configure("Server"), offers.Offers{Configuration: configure("Server")}, ":4020")
	go func() {
		if err := server.Start(); err != nil {
			panic(err)
		}
	}()

	// Client
	var client = offers.MustNewClient(configure("Client"), ":4020").ForContext(offers.Context{ID: tigertonic.RandomBase62String(8)}).(offers.Client)

	// Use
	var m = offer.Offer{Interface: client, Name: "nerddomo"}
	m, err := m.New()
	if err != nil {
		panic(err)
	}
	log.Printf("New: Got: %# v\n\n", pretty.Formatter(simplify(m)))
	m, err = client.Get(m.ID)
	if err != nil {
		panic(err)
	}
	log.Printf("Get: Got: %# v\n\n", pretty.Formatter(simplify(m)))
	m.Name = "bar"
	m, err = m.Set()
	if err != nil {
		panic(err)
	}
	log.Printf("Set: Got: %# v\n\n", pretty.Formatter(simplify(m)))
	m, err = m.Delete()
	if err != nil {
		panic(err)
	}
	log.Printf("Delete: Got: %# v\n\n", pretty.Formatter(simplify(m)))

	// Client
	if err := client.Close(); err != nil {
		panic(err)
	}

	// Server
	if err := server.Stop(); err != nil {
		panic(err)
	}
}
开发者ID:willfaught,项目名称:services,代码行数:49,代码来源:main.go



注:本文中的github.com/kr/pretty.Formatter函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang pretty.Println函数代码示例发布时间:2022-05-23
下一篇:
Golang pretty.Diff函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap