49
50// AssignedChars returns a list of all the text characters assigned to an operation
51func (widget *KeyboardWidget) AssignedChars() []string {
52 chars := []string{} 53
54 for char := range widget.charMap {
55 chars = append(chars, char)
46 tbl.tblWriter.SetColMinWidth(0, colWidth0)
47 tbl.tblWriter.SetColMinWidth(1, colWidth1)
48
49 keys := []string{}50 for key := range dataMap {
51 keys = append(keys, key)
52 }
33// b := FindBetween(a, "{", "}")
34// > [" cat ", " dog "]
35func FindBetween(input string, left string, right string) []string {
36 out := []string{} 37
38 i := 0
39 for i >= 0 {
42// It takes a list of OpenWeatherMap city IDs.
43// It returns a list of OpenWeatherMap CurrentWeatherData structs, one per valid city code.
44func (widget *Widget) Fetch(cityIDs []int) []*owm.CurrentWeatherData {
45 data := []*owm.CurrentWeatherData{} 46
47 for _, cityID := range cityIDs {
48 result, err := widget.currentWeather(cityID)
55}
56
57func (widget *Widget) description(cityData *owm.CurrentWeatherData) string {
58 descs := []string{} 59 for _, weather := range cityData.Weather {
60 descs = append(descs, fmt.Sprintf(" %s", weather.Description))
61 }
An empty slice can be represented by nil
or an empty slice literal. They are
functionally equivalent — their len
and cap
are both zero — but the nil
slice is the preferred style. For more information about empty slices,
see Declaring Empty Slices.
package main
func foo() {
a := []int{}
}
package main
func foo() {
var a []int
}