本文整理汇总了Golang中github.com/turnkey-commerce/go-ping-sites/database.Site.Contacts方法的典型用法代码示例。如果您正苦于以下问题:Golang Site.Contacts方法的具体用法?Golang Site.Contacts怎么用?Golang Site.Contacts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/turnkey-commerce/go-ping-sites/database.Site
的用法示例。
在下文中一共展示了Site.Contacts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetSitesMock
// GetSitesMock is a mock of the SQL query to get the sites for pinging
func GetSitesMock(db *sql.DB) (database.Sites, error) {
var sites database.Sites
// Create the first site.
s1 := database.Site{Name: "Test", IsActive: true, URL: "http://www.google.com",
PingIntervalSeconds: 1, TimeoutSeconds: 1, IsSiteUp: true}
// Create the second site.
s2 := database.Site{Name: "Test 2", IsActive: true, URL: "http://www.github.com",
PingIntervalSeconds: 2, TimeoutSeconds: 2, IsSiteUp: true}
// Create the third site as not active.
s3 := database.Site{Name: "Test 3", IsActive: false, URL: "http://www.test.com",
PingIntervalSeconds: 2, TimeoutSeconds: 2}
// Contacts are deliberately set as false for SmsActive and EmailActive so as not to trigger Notifier
c1 := database.Contact{Name: "Joe Contact", EmailAddress: "[email protected]", SmsNumber: "5125551212",
SmsActive: false, EmailActive: false}
c2 := database.Contact{Name: "Jack Contact", EmailAddress: "[email protected]", SmsNumber: "5125551213",
SmsActive: false, EmailActive: false}
// Add the contacts to the sites
s1.Contacts = append(s1.Contacts, c1, c2)
s2.Contacts = append(s2.Contacts, c1)
s3.Contacts = append(s3.Contacts, c1)
sites = append(sites, s1, s2, s3)
return sites, nil
}
示例2: getTestSite
// Create the struct for the Site and its contacts used for testing.
func getTestSite() database.Site {
s1 := database.Site{Name: "Test", IsActive: true, URL: "http://www.google.com",
PingIntervalSeconds: 2, TimeoutSeconds: 1}
// Create first contact
c1 := database.Contact{Name: "Joe Contact", EmailAddress: "[email protected]", SmsNumber: "5125551212",
SmsActive: false, EmailActive: true}
// Create second contact
c2 := database.Contact{Name: "Jack Contact", EmailAddress: "[email protected]", SmsNumber: "5125551213",
SmsActive: true, EmailActive: false}
// Add the contacts to the sites
s1.Contacts = append(s1.Contacts, c1, c2)
return s1
}