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

Golang util.CheckErr函数代码示例

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

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



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

示例1: SetUpSuite

func (m *MongoSearchSuite) SetUpSuite(c *C) {
	m.EST = time.FixedZone("EST", -5*60*60)
	m.Local, _ = time.LoadLocation("Local")

	//turnOnDebugLog()

	// Set up the database
	m.DBServer = &dbtest.DBServer{}
	m.DBServer.SetPath(c.MkDir())

	m.Session = m.DBServer.Session()
	db := m.Session.DB("fhir-test")
	m.MongoSearcher = &MongoSearcher{db}

	// Read in the data in FHIR format
	data, err := ioutil.ReadFile("../fixtures/search_test_data.json")
	util.CheckErr(err)

	maps := make([]interface{}, 19)
	err = json.Unmarshal(data, &maps)
	util.CheckErr(err)

	for _, resourceMap := range maps {
		r := models.MapToResource(resourceMap, true)
		collection := models.PluralizeLowerResourceName(reflect.TypeOf(r).Elem().Name())
		util.CheckErr(db.C(collection).Insert(r))
	}
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:28,代码来源:mongo_search_test.go


示例2: TestEncounterTypeQueryWithCountAndOffset

func (m *MongoSearchSuite) TestEncounterTypeQueryWithCountAndOffset(c *C) {
	// First do with an offset of 1
	q := Query{"Encounter", "type=http://www.ama-assn.org/go/cpt|99201&_offset=1&_count=1"}
	mq := m.MongoSearcher.CreateQuery(q)

	num, err := mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 1)

	offset1 := &models.Encounter{}
	err = mq.One(offset1)
	util.CheckErr(err)

	// Now do an offset of 2
	q = Query{"Encounter", "type=http://www.ama-assn.org/go/cpt|99201&_offset=2&_count=1"}
	mq = m.MongoSearcher.CreateQuery(q)

	num, err = mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 1)

	offset2 := &models.Encounter{}
	err = mq.One(offset2)
	util.CheckErr(err)

	// Now make sure they are not the same
	c.Assert(offset1.Id, Not(Equals), offset2.Id)
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:28,代码来源:mongo_search_test.go


示例3: TestUnconfirmedResourcesDontGenerateEvents

func (s *ServiceSuite) TestUnconfirmedResourcesDontGenerateEvents(c *C) {
	data, err := ioutil.ReadFile("fixtures/brad_bradworth_event_source_bundle.json")
	util.CheckErr(err)

	bundle := new(models.Bundle)
	json.Unmarshal(data, bundle)

	// Switch a few resources to be unconfirmed
	bundle.Entry[2].Resource.(*models.Condition).VerificationStatus = "refuted"
	bundle.Entry[4].Resource.(*models.MedicationStatement).Status = "entered-in-error"

	es, err := BundleToEventStream(bundle)
	util.CheckErr(err)

	c.Assert(es.Patient, NotNil)
	c.Assert(es.Patient.Id, Equals, "507f1f77bcf86cd799439001")
	c.Assert(es.Events, HasLen, 3)
	loc := time.FixedZone("-0500", -5*60*60)
	// Event 0 (Condition: Atrial Fibrillation)
	c.Assert(es.Events[0].Date.Equal(time.Date(2012, time.September, 20, 8, 0, 0, 0, loc)), Equals, true)
	c.Assert(es.Events[0].Type, Equals, "Condition")
	c.Assert(es.Events[0].End, Equals, false)
	c.Assert(es.Events[0].Value, DeepEquals, bundle.Entry[1].Resource)
	// Event 1 (Condition: Cerebral infarction due to cerebral artery occlusion)
	c.Assert(es.Events[1].Date.Equal(time.Date(2014, time.January, 17, 20, 35, 0, 0, loc)), Equals, true)
	c.Assert(es.Events[1].Type, Equals, "Condition")
	c.Assert(es.Events[1].End, Equals, false)
	c.Assert(es.Events[1].Value, DeepEquals, bundle.Entry[3].Resource)
	// Event 2 (Condition END: Cerebral infarction due to cerebral artery occlusion)
	c.Assert(es.Events[2].Date.Equal(time.Date(2014, time.January, 17, 20, 40, 0, 0, loc)), Equals, true)
	c.Assert(es.Events[2].Type, Equals, "Condition")
	c.Assert(es.Events[2].End, Equals, true)
	c.Assert(es.Events[2].Value, DeepEquals, bundle.Entry[3].Resource)
}
开发者ID:intervention-engine,项目名称:riskservice,代码行数:34,代码来源:service_test.go


示例4: performSearch

func performSearch(c *C, url string) *models.Bundle {
	res, err := http.Get(url)
	util.CheckErr(err)
	decoder := json.NewDecoder(res.Body)
	bundle := &models.Bundle{}
	err = decoder.Decode(bundle)
	util.CheckErr(err)
	return bundle
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:9,代码来源:server_test.go


示例5: TestGetPatient

func (s *ServerSuite) TestGetPatient(c *C) {
	res, err := http.Get(s.Server.URL + "/Patient/" + s.FixtureId)
	util.CheckErr(err)

	decoder := json.NewDecoder(res.Body)
	patient := &models.Patient{}
	err = decoder.Decode(patient)
	util.CheckErr(err)
	c.Assert(patient.Name[0].Family[0], Equals, "Donald")
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:10,代码来源:server_test.go


示例6: LoadBundleFromFixture

func LoadBundleFromFixture(fileName string) *Bundle {
	data, err := os.Open(fileName)
	defer data.Close()
	util.CheckErr(err)
	decoder := json.NewDecoder(data)
	bundle := &Bundle{}
	err = decoder.Decode(bundle)
	util.CheckErr(err)
	return bundle
}
开发者ID:dhf0820,项目名称:fhir-1,代码行数:10,代码来源:bundle_test.go


示例7: loadPatientFromFixture

func loadPatientFromFixture(fileName string) *models.Patient {
	data, err := os.Open(fileName)
	defer data.Close()
	util.CheckErr(err)
	decoder := json.NewDecoder(data)
	patient := &models.Patient{}
	err = decoder.Decode(patient)
	util.CheckErr(err)
	return patient
}
开发者ID:dhf0820,项目名称:fhir-1,代码行数:10,代码来源:server_test.go


示例8: LoadMapFromFixture

func LoadMapFromFixture(fileName string) interface{} {
	data, err := os.Open(fileName)
	defer data.Close()
	util.CheckErr(err)
	decoder := json.NewDecoder(data)
	i := make(map[string]interface{})
	err = decoder.Decode(&i)
	util.CheckErr(err)
	return i
}
开发者ID:dhf0820,项目名称:fhir-1,代码行数:10,代码来源:util_test.go


示例9: SetUpSuite

func (r *RecordMatchRunSuite) SetUpSuite(c *C) {
	data, err := os.Open("../fixtures/record-match-run-responses.json")
	util.CheckErr(err)
	defer data.Close()

	decoder := json.NewDecoder(data)
	rmr := &RecordMatchRun{}
	err = decoder.Decode(rmr)
	util.CheckErr(err)
	r.Run = rmr
}
开发者ID:mitre,项目名称:ptmatch,代码行数:11,代码来源:record_match_run_test.go


示例10: do_dact

func do_dact(filename string) {
	reader, err := dbxml.Open(filename)
	util.CheckErr(err)
	fmt.Println(">>>", filename)
	docs, err := reader.All()
	util.CheckErr(err)
	for docs.Next() {
		do_data(filename, docs.Name(), []byte(docs.Content()))
	}
	showmemstats()
	reader.Close()
}
开发者ID:rug-compling,项目名称:paqu,代码行数:12,代码来源:dbxml_true.go


示例11: TestConditionReferenceQueryByPatientGender

func (m *MongoSearchSuite) TestConditionReferenceQueryByPatientGender(c *C) {
	q := Query{"Condition", "patient.gender=male"}
	mq := m.MongoSearcher.CreateQuery(q)
	num, err := mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 5)

	q = Query{"Condition", "patient.gender=female"}
	mq = m.MongoSearcher.CreateQuery(q)
	num, err = mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 1)
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:13,代码来源:mongo_search_test.go


示例12: TestPatientNameStringQuery

func (m *MongoSearchSuite) TestPatientNameStringQuery(c *C) {
	q := Query{"Patient", "name=Peters"}
	mq := m.MongoSearcher.CreateQuery(q)
	num, err := mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 2)

	q = Query{"Patient", "name=John"}
	mq = m.MongoSearcher.CreateQuery(q)
	num, err = mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 1)
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:13,代码来源:mongo_search_test.go


示例13: TestImmunizationDoseSequenceWrongNumberQuery

func (m *MongoSearchSuite) TestImmunizationDoseSequenceWrongNumberQuery(c *C) {
	q := Query{"Immunization", "dose-sequence=0"}
	mq := m.MongoSearcher.CreateQuery(q)
	num, err := mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 0)

	q = Query{"Immunization", "dose-sequence=2"}
	mq = m.MongoSearcher.CreateQuery(q)
	num, err = mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 0)
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:13,代码来源:mongo_search_test.go


示例14: main

func main() {
	data, err := ioutil.ReadFile("xpath.xml")
	util.CheckErr(err)

	doc, err := xml.Parse(data, nil, nil, 0, xml.DefaultEncodingBytes)
	util.CheckErr(err)
	defer doc.Free()

	n, err := doc.Root().Search(`/probe/header/@vendor`)
	fmt.Println("Vendor:")
	fmt.Println(n)
	util.CheckErr(err)
}
开发者ID:rofrol,项目名称:gokogiri-example,代码行数:13,代码来源:main.go


示例15: TestFindResultsForMeasurePopulation

func (i *IndividualResultSuite) TestFindResultsForMeasurePopulation(c *C) {
	pq := PopulationQuery{MeasureID: "efgh", EffectiveDate: 1234, Population: InitialPatientPopulation}
	pr, err := FindResultsForMeasurePopulation(i.Database, pq)
	util.CheckErr(err)
	c.Assert(pr.Total, Equals, 2)
	pt := pr.Patients[0]
	c.Assert(pt.Last, Equals, "A")
	pq.Population = Denominator
	pr, err = FindResultsForMeasurePopulation(i.Database, pq)
	util.CheckErr(err)
	c.Assert(pr.Total, Equals, 1)
	pt = pr.Patients[0]
	c.Assert(pt.Last, Equals, "A")
}
开发者ID:mitre,项目名称:ecqm,代码行数:14,代码来源:individual_result_test.go


示例16: TestFindOrCreateQualityReport

func (q *QualityReportSuite) TestFindOrCreateQualityReport(c *C) {
	qr := &QualityReport{MeasureID: "abcd", EffectiveDate: 1234, NPI: "efg"}
	id := bson.NewObjectId()
	qr.ID = id
	q.Database.C("query_cache").Insert(qr)
	qrToFind := &QualityReport{MeasureID: "abcd", EffectiveDate: 1234}
	err := FindOrCreateQualityReport(q.Database, qrToFind)
	util.CheckErr(err)
	c.Assert(qrToFind.NPI, Equals, "efg")
	qrDoesntExist := &QualityReport{MeasureID: "foobar", EffectiveDate: 1234}
	err = FindOrCreateQualityReport(q.Database, qrDoesntExist)
	util.CheckErr(err)
	count, _ := q.Database.C("query_cache").Count()
	c.Assert(count, Equals, 2)
}
开发者ID:mitre,项目名称:ecqm,代码行数:15,代码来源:quality_report_test.go


示例17: TestFindQualityAndPopulateQualityReport

func (q *QualityReportSuite) TestFindQualityAndPopulateQualityReport(c *C) {
	qr := &QualityReport{MeasureID: "abcd", EffectiveDate: 1234, NPI: "efg"}
	id := bson.NewObjectId()
	qr.ID = id
	q.Database.C("query_cache").Insert(qr)
	qrToFind := &QualityReport{MeasureID: "abcd", EffectiveDate: 1234}
	exists, err := FindQualityAndPopulateQualityReport(q.Database, qrToFind)
	util.CheckErr(err)
	c.Assert(exists, Equals, true)
	c.Assert(qrToFind.NPI, Equals, "efg")
	qrDoesntExist := &QualityReport{MeasureID: "foobar", EffectiveDate: 1234}
	exists, err = FindQualityAndPopulateQualityReport(q.Database, qrDoesntExist)
	util.CheckErr(err)
	c.Assert(exists, Equals, false)
}
开发者ID:mitre,项目名称:ecqm,代码行数:15,代码来源:quality_report_test.go


示例18: TestUpdatePatient

func (s *ServerSuite) TestUpdatePatient(c *C) {
	data, err := os.Open("../fixtures/patient-example-c.json")
	util.CheckErr(err)
	defer data.Close()

	client := &http.Client{}
	req, err := http.NewRequest("PUT", s.Server.URL+"/Patient/"+s.FixtureId, data)
	util.CheckErr(err)
	_, err = client.Do(req)

	patientCollection := Database.C("patients")
	patient := models.Patient{}
	err = patientCollection.Find(bson.M{"_id": s.FixtureId}).One(&patient)
	util.CheckErr(err)
	c.Assert(patient.Name[0].Family[0], Equals, "Darkwing")
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:16,代码来源:server_test.go


示例19: TestNonMatchingDeviceStringQuery

func (m *MongoSearchSuite) TestNonMatchingDeviceStringQuery(c *C) {
	q := Query{"Device", "manufacturer=Zinc"}
	mq := m.MongoSearcher.CreateQuery(q)
	num, err := mq.Count()
	util.CheckErr(err)
	c.Assert(num, Equals, 0)
}
开发者ID:ghchinoy,项目名称:fhir,代码行数:7,代码来源:mongo_search_test.go


示例20: main

func main() {
	doUtf8 := true
	doRaw := true

	if util.IsTerminal(os.Stdin) {
		syntax()
		return
	}

	for _, arg := range os.Args[1:] {
		switch arg {
		case "-r":
			doUtf8 = false
		case "-u":
			doRaw = false
		default:
			syntax()
			return
		}
	}
	if !doUtf8 && !doRaw {
		syntax()
		return
	}

	data, err := ioutil.ReadAll(os.Stdin)
	util.CheckErr(err)
	str := string(data)

	if doRaw {
		fmt.Println("[[[RAW]]]")
		n := 0
		for i, p := range textcat.GetPatterns(str, false) {
			if i == textcat.MaxPatterns {
				break
			}
			n += 1
			fmt.Printf("%s\t%d\n", p.S, p.I)
		}
		if n < textcat.MaxPatterns {
			fmt.Fprintf(os.Stderr, "Warning: there are less than %d raw patterns\n", textcat.MaxPatterns)
		}
	}

	if doUtf8 {
		fmt.Println("[[[UTF8]]]")
		n := 0
		for i, p := range textcat.GetPatterns(str, true) {
			if i == textcat.MaxPatterns {
				break
			}
			n += 1
			fmt.Printf("%s\t%d\n", p.S, p.I)
		}
		if n < textcat.MaxPatterns {
			fmt.Fprintf(os.Stderr, "Warning: there are less than %d utf8 patterns\n", textcat.MaxPatterns)
		}
	}

}
开发者ID:postfix,项目名称:textcat,代码行数:60,代码来源:textpat.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang zmq2.NewPoller函数代码示例发布时间:2022-05-28
下一篇:
Golang digitalocean.Droplet类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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