123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package main
- import (
- "bufio"
- "fmt"
- "io"
- "os"
- "strings"
- "time"
- )
- func main() {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- timeTemplate := "2006-01-02"
- t, _ := time.ParseInLocation(timeTemplate, "2010-01-01", time.Local)
- fmt.Println(int(t.Weekday()), t.AddDate(0, 1, -1))
- }
- func ReadFile(filename string) []string {
- var words []string
- file, err := os.Open(filename)
- if err != nil {
- panic(err)
- }
- defer file.Close()
- reader := bufio.NewReader(file)
- for {
- line, err := reader.ReadString('\n')
- if err != nil || io.EOF == err {
- break
- }
- wordSlice := strings.Fields(line)
- for _, word := range wordSlice {
- if word = extractStr(strings.ToLower(word)); word != "" {
- words = append(words, word)
- }
- }
- }
- return words
- }
- func extractStr(str string) string {
- var res []rune
- for _, letter := range str {
- if letter >= 'a' && letter <= 'z' {
- res = append(res, letter)
- }
- }
- return string(res)
- }
|