# emerge -pv pkg-config
Calculating dependencies... done!
[ebuild N ] dev-libs/libyaml-0.1.6 USE="-doc -examples -static-libs {-test}" 492 kB
[ebuild N ] app-eselect/eselect-ruby-20131227 2 kB
[ebuild N ] dev-util/ragel-6.7-r1 USE="-vim-syntax" 1,156 kB
[ebuild N ] dev-lang/ruby-2.0.0_p647-r1:2.0 USE="berkdb gdbm ipv6 ncurses rdoc readline ssl -debug -doc -examples -rubytests -socks5 -xemacs" CPU_FLAGS_X86="sse2" 8,110 kB
[ebuild N ] dev-lang/ruby-2.1.7:2.1 USE="berkdb gdbm ipv6 ncurses rdoc readline ssl -debug -doc -examples -rubytests -socks5 -xemacs" 9,154 kB
[ebuild N ] dev-ruby/rubygems-2.2.5-r1 USE="-server {-test}" RUBY_TARGETS="ruby20 ruby21 (-ruby19)" 408 kB
[ebuild N ] virtual/rubygems-10 RUBY_TARGETS="ruby20 ruby21 (-ruby19)" 0 kB
[ebuild N ] dev-ruby/rake-0.9.6-r1 USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21 (-ruby19)" 121 kB
[ebuild N ] dev-ruby/json-1.8.2-r1 USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21 (-ruby19)" 149 kB
[ebuild N ] dev-ruby/racc-1.4.11 USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21 (-ruby19)" 111 kB
[ebuild N ] dev-ruby/rdoc-4.0.1-r2 USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21 (-ruby19)" 457 kB
[ebuild N ] dev-ruby/pkg-config-1.1.5 USE="{-test}" RUBY_TARGETS="ruby20 (-ruby19)" 19 kB
Total: 12 packages (12 new), Size of downloads: 20,175 kB
# apt get pkg-config
# yim install pkg-config
pkg-cinfig: exec: "pkg-config": executable file not found in %PATH%
запуск "pkg-config": исполняемый файл не найден в %PATH%
func OpenFile(filename string) (file *File, err error)
type File struct {
Date1904 bool
Sheets []*Sheet
Sheet map[string]*Sheet
// contains filtered or unexported fields
}
type Sheet struct {
Name string
File *File
Rows []*Row
Cols []*Col
MaxRow int
MaxCol int
Hidden bool
Selected bool
SheetViews []SheetView
SheetFormat SheetFormat
}
package main
import "fmt"
import "time"
func getDataFromServer(res chan string, serverName string, delay int64) {
fmt.Println(serverName)
time.Sleep(time.Duration(delay)*time.Second)
res <- "test_"+serverName
}
func main() {
res := make(chan string, 3)
go getDataFromServer(res, "Server1", 10)
go getDataFromServer(res, "Server2", 11)
go getDataFromServer(res, "Server3", 12)
data := <- res
fmt.Println(data)
}
Server3
Server1
Server2
test_Server1
package main
import "fmt"
import "time"
func getDataFromServer(res chan string, serverName string, delay int64) {
fmt.Println(serverName)
time.Sleep(time.Duration(delay)*time.Second)
res <- "test_"+serverName
}
func main() {
res := make(chan string, 3)
go getDataFromServer(res, "Server1", 15)
go getDataFromServer(res, "Server2", 11)
go getDataFromServer(res, "Server3", 12)
data := <- res
fmt.Println(data)
}
Server3
Server1
Server2
test_Server2
package main
import mypackage
func init() {
... что-то сделали, что-то инициализировали, например доступ к базе или ещё чему
... ещё что-то инициализировали...
... начинаем инициализировать mypackage
mypackage.DB = DB // проинициализировали доступ в базу в пакете:)
mypackage.Other = Other // ещё что-то проинициализировали в пакете...
}
func main() {
... другой вопрос что можно и так, но в этом случае в пакете чуть больше логики...
obj := package.Init()
obj.SetDB(DB)
obj.SetOther(Other)
go obj.Start()
}
Examples
Here are some example one-line templates demonstrating pipelines and variables. All produce the quoted word "output":{{"\"output\""}} A string constant. {{`"output"`}} A raw string constant. {{printf "%q" "output"}} A function call. {{"output" | printf "%q"}} A function call whose final argument comes from the previous command. {{printf "%q" (print "out" "put")}} A parenthesized argument. {{"put" | printf "%s%s" "out" | printf "%q"}} A more elaborate call. {{"output" | printf "%s" | printf "%q"}} A longer chain. {{with "output"}}{{printf "%q" .}}{{end}} A with action using dot. {{with $x := "output" | printf "%q"}}{{$x}}{{end}} A with action that creates and uses a variable. {{with $x := "output"}}{{printf "%q" $x}}{{end}} A with action that uses the variable in another action. {{with $x := "output"}}{{$x | printf "%q"}}{{end}} The same, but pipelined.
func (t *Template) Delims(left, right string) *Template
package main
import "mypackage"
// import DB package
var DB *sql.DB
func init() {
DB = sql.Open()
mypackage.DB = DB
}
func main() {
mypackage.myfunction1()
mypackage.myfunction2()
}