Compare commits
3 Commits
7f6f1ffaa6
...
a0c8142948
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a0c8142948 | ||
![]() |
6ee5b499fa | ||
![]() |
4a5a154ab8 |
21
Software/Applications/VSCode/VSCode_调试程序_Scanf_无法输入问题.md
Normal file
21
Software/Applications/VSCode/VSCode_调试程序_Scanf_无法输入问题.md
Normal file
@ -0,0 +1,21 @@
|
||||
# VSCode 调试程序 Scanf 无法输入问题
|
||||
|
||||
VSCode 调试 C/C++/Golang 等程序时,遇到 fmt.Scan/fmt.Scanf/fmt.Scanln 等输入时,在 Debug Console 中是无法输入的。
|
||||
|
||||
解决办法是在调试的 launch.json 中添加:"console": "integratedTerminal",如下:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"configurations": [
|
||||
// ...
|
||||
{
|
||||
// ...
|
||||
"console": "integratedTerminal",
|
||||
// ...
|
||||
},
|
||||
// ...
|
||||
],
|
||||
// ...
|
||||
}
|
||||
```
|
@ -255,16 +255,22 @@ func ListDir(dir, suffix string) (files []string, err error) {
|
||||
|
||||
suffix = strings.ToLower(suffix) //匹配后缀
|
||||
|
||||
for _, _file := range _dir {
|
||||
if _file.IsDir() {
|
||||
continue //忽略目录
|
||||
for _, file := range _dir {
|
||||
if file.IsDir() {
|
||||
// 递归读取子目录下的文件
|
||||
sub := filepath.Join(dir, file.Name())
|
||||
fs, err := ListDir(sub, suffix)
|
||||
if len(fs) != 0 && err == nil {
|
||||
files = append(files, fs...)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if len(suffix) == 0 {
|
||||
// 不需要匹配文件后缀
|
||||
files = append(files, filepath.Join(dir, _file.Name()))
|
||||
} else if strings.HasSuffix(strings.ToLower(_file.Name()), suffix) {
|
||||
files = append(files, filepath.Join(dir, file.Name()))
|
||||
} else if strings.HasSuffix(strings.ToLower(file.Name()), suffix) {
|
||||
// 文件后缀匹配
|
||||
files = append(files, filepath.Join(dir, _file.Name()))
|
||||
files = append(files, filepath.Join(dir, file.Name()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ import (
|
||||
|
||||
I published an update to a Go module, bumping the version to v1.1.0. I created a tag named v1.1.0 and pushed the tag to GitHub.
|
||||
|
||||
https://github.com/depp/bytesize/releases/tag/v1.1.0
|
||||
<https://github.com/depp/bytesize/releases/tag/v1.1.0>
|
||||
|
||||
However, I cannot use this package in my other projects. I get an error that says, "invalid version: unknown revision v1.1.0". I don't know why the revision is "unknown", since it's tagged.
|
||||
|
||||
@ -122,22 +122,24 @@ The tag was pushed after invoking go get once, which poisoned the Go module prox
|
||||
|
||||
From <https://proxy.golang.org/>:
|
||||
|
||||
Note that if someone requested the version before the tag was pushed, it may take up to 30 minutes for the mirror's cache to expire and fresh data about the version to become available.
|
||||
```txt
|
||||
Note that if someone requested the version before the tag was pushed, it may take up to 30 minutes for the mirror's cache to expire and fresh data about the version to become available.
|
||||
```
|
||||
|
||||
The way to work around this before the cache expires is to use the GOPRIVATE environment variable to instruct go get to fetch this module directly, bypassing the cache.
|
||||
|
||||
From <https://golang.org/cmd/go/>:
|
||||
|
||||
GOPRIVATE, GONOPROXY, GONOSUMDB
|
||||
```txt
|
||||
GOPRIVATE, GONOPROXY, GONOSUMDB
|
||||
|
||||
Comma-separated list of glob patterns (in the syntax of Go's path.Match) of module path prefixes that should always be fetched directly or that should not be compared against the checksum database.
|
||||
Comma-separated list of glob patterns (in the syntax of Go's path.Match) of module path prefixes that should always be fetched directly or that should not be compared against the checksum database.
|
||||
```
|
||||
|
||||
The workaround is:
|
||||
|
||||
```bash
|
||||
$ GOPRIVATE=github.com/depp/bytesize go get github.com/depp/bytesize@v1.1.0
|
||||
GOPRIVATE=github.com/depp/bytesize go get github.com/depp/bytesize@v1.1.0
|
||||
```
|
||||
|
||||
Note that if you are already using GOPRIVATE, you will want to add modules rather than overriding the value completely.
|
||||
|
||||
|
||||
|
@ -90,7 +90,7 @@ filepath.Match("/home/catch/*", "/home/catch/foo/bar")
|
||||
|
||||
```go
|
||||
/**
|
||||
* 获取主文件名嗯
|
||||
* 获取主文件名
|
||||
* 输出:my.demo
|
||||
*/
|
||||
filename := "my.demo.jpg"
|
||||
|
@ -0,0 +1,183 @@
|
||||
# Golang Time 格式化输出
|
||||
|
||||
```go
|
||||
time.Now().Format("2006-01-02 15:04:05")
|
||||
```
|
||||
|
||||
Format layout 如下表:
|
||||
|
||||
| Unit | Golang Layout | Examples | Note |
|
||||
|-------------|---------------|-----------------------------------|----------------------------------|
|
||||
| Year | 06 | 21, 81, 01 | |
|
||||
| Year | 2006 | 2021, 1981, 0001 | |
|
||||
| Month | January | January, February, December | |
|
||||
| Month | Jan | Jan, Feb, Dec | |
|
||||
| Month | 1 | 1, 2, 12 | |
|
||||
| Month | 01 | 01, 02, 12 | |
|
||||
| Day | Monday | Monday, Wednesday, Sunday | |
|
||||
| Day | Mon | Mon, Wed, Sun | |
|
||||
| Day | 2 | 1, 2, 11, 31 | |
|
||||
| Day | 02 | 01, 02, 11, 31 | zero padded day of the month |
|
||||
| Day | _2 | ⎵1, ⎵2, 11, 31 | space padded day of the month |
|
||||
| Day | 002 | 001, 002, 011, 031, 145, 365, 366 | zero padded day of the year |
|
||||
| Day | __2 | ⎵⎵1, ⎵⎵2, ⎵11, ⎵31, 365, 366 | space padded day of the year |
|
||||
| Part of day | PM | AM, PM | |
|
||||
| Part of day | pm | am, pm | |
|
||||
| Hour 24h | 15 | 00, 01, 12, 23 | |
|
||||
| Hour 12h | 3 | 1, 2, 12 | |
|
||||
| Hour 12h | 03 | 01, 02, 12 | |
|
||||
| Minute | 4 | 0, 4 ,10, 35 | |
|
||||
| Minute | 04 | 00, 04 ,10, 35 | |
|
||||
| Second | 5 | 0, 5, 25 | |
|
||||
| Second | 05 | 00, 05, 25 | |
|
||||
| Decisecond | .0 | .1 | Trailing zeros included (. or ,) |
|
||||
| Millisecond | .000 | .100 | Trailing zeros included (. or ,) |
|
||||
| Nanosecond | .000000000 | .199000000 | Trailing zeros included (. or ,) |
|
||||
| Decisecond | .9 | .1 | Trailing zeros omitted (. or ,) |
|
||||
| Millisecond | .999 | .19 | Trailing zeros omitted (. or ,) |
|
||||
| Nanosecond | .999999999 | .199 | Trailing zeros omitted (. or ,) |
|
||||
| Time zone | MST | UTC, MST, CET | |
|
||||
| Time zone | Z07 | Z, +08, -05 | Z is for UTC |
|
||||
| Time zone | Z0700 | Z, +0800, -0500 | Z is for UTC |
|
||||
| Time zone | Z070000 | Z, +080000, -050000 | Z is for UTC |
|
||||
| Time zone | Z07:00 | Z, +08:00, -05:00 | Z is for UTC |
|
||||
| Time zone | Z07:00:00 | Z, +08:00:00, -05:00:00 | Z is for UTC |
|
||||
| Time zone | -07 | +00, +08, -05 | |
|
||||
| Time zone | -0700 | +0000, +0800, -0500 | |
|
||||
| Time zone | -070000 | +000000, +080000, -050000 | |
|
||||
| Time zone | -07:00 | +00:00, +08:00, -05:00 | |
|
||||
| Time zone | -07:00:00 | +00:00:00, +08:00:00, -05:00:00 | |
|
||||
|
||||
还可以使用 Golang 预先设定好的 Layout 风格:
|
||||
|
||||
```go
|
||||
now := time.Now()
|
||||
fmt.Println(now) // 2009-11-10 23:00:00 +0000 UTC m=+0.000000001
|
||||
fmt.Println(now.Format(time.Layout)) // 01/02 03:04:05PM '06 -0700
|
||||
fmt.Println(now.Format(time.ANSIC)) // Mon Jan _2 15:04:05 2006
|
||||
fmt.Println(now.Format(time.UnixDate)) // Mon Jan _2 15:04:05 MST 2006
|
||||
fmt.Println(now.Format(time.RubyDate)) // Mon Jan 02 15:04:05 -0700 2006
|
||||
fmt.Println(now.Format(time.RFC822)) // 02 Jan 06 15:04 MST
|
||||
fmt.Println(now.Format(time.RFC850)) // Monday, 02-Jan-06 15:04:05 MST
|
||||
fmt.Println(now.Format(time.Kitchen)) // 3:04PM
|
||||
fmt.Println(now.Format(time.Stamp)) // Jan _2 15:04:05
|
||||
```
|
||||
|
||||
定义在 time 包的 format.go 文件中:
|
||||
|
||||
```go
|
||||
// These are predefined layouts for use in Time.Format and time.Parse.
|
||||
// The reference time used in these layouts is the specific time stamp:
|
||||
//
|
||||
// 01/02 03:04:05PM '06 -0700
|
||||
//
|
||||
// (January 2, 15:04:05, 2006, in time zone seven hours west of GMT).
|
||||
// That value is recorded as the constant named Layout, listed below. As a Unix
|
||||
// time, this is 1136239445. Since MST is GMT-0700, the reference would be
|
||||
// printed by the Unix date command as:
|
||||
//
|
||||
// Mon Jan 2 15:04:05 MST 2006
|
||||
//
|
||||
// It is a regrettable historic error that the date uses the American convention
|
||||
// of putting the numerical month before the day.
|
||||
//
|
||||
// The example for Time.Format demonstrates the working of the layout string
|
||||
// in detail and is a good reference.
|
||||
//
|
||||
// Note that the RFC822, RFC850, and RFC1123 formats should be applied
|
||||
// only to local times. Applying them to UTC times will use "UTC" as the
|
||||
// time zone abbreviation, while strictly speaking those RFCs require the
|
||||
// use of "GMT" in that case.
|
||||
// In general RFC1123Z should be used instead of RFC1123 for servers
|
||||
// that insist on that format, and RFC3339 should be preferred for new protocols.
|
||||
// RFC3339, RFC822, RFC822Z, RFC1123, and RFC1123Z are useful for formatting;
|
||||
// when used with time.Parse they do not accept all the time formats
|
||||
// permitted by the RFCs and they do accept time formats not formally defined.
|
||||
// The RFC3339Nano format removes trailing zeros from the seconds field
|
||||
// and thus may not sort correctly once formatted.
|
||||
//
|
||||
// Most programs can use one of the defined constants as the layout passed to
|
||||
// Format or Parse. The rest of this comment can be ignored unless you are
|
||||
// creating a custom layout string.
|
||||
//
|
||||
// To define your own format, write down what the reference time would look like
|
||||
// formatted your way; see the values of constants like ANSIC, StampMicro or
|
||||
// Kitchen for examples. The model is to demonstrate what the reference time
|
||||
// looks like so that the Format and Parse methods can apply the same
|
||||
// transformation to a general time value.
|
||||
//
|
||||
// Here is a summary of the components of a layout string. Each element shows by
|
||||
// example the formatting of an element of the reference time. Only these values
|
||||
// are recognized. Text in the layout string that is not recognized as part of
|
||||
// the reference time is echoed verbatim during Format and expected to appear
|
||||
// verbatim in the input to Parse.
|
||||
//
|
||||
// Year: "2006" "06"
|
||||
// Month: "Jan" "January" "01" "1"
|
||||
// Day of the week: "Mon" "Monday"
|
||||
// Day of the month: "2" "_2" "02"
|
||||
// Day of the year: "__2" "002"
|
||||
// Hour: "15" "3" "03" (PM or AM)
|
||||
// Minute: "4" "04"
|
||||
// Second: "5" "05"
|
||||
// AM/PM mark: "PM"
|
||||
//
|
||||
// Numeric time zone offsets format as follows:
|
||||
//
|
||||
// "-0700" ±hhmm
|
||||
// "-07:00" ±hh:mm
|
||||
// "-07" ±hh
|
||||
// "-070000" ±hhmmss
|
||||
// "-07:00:00" ±hh:mm:ss
|
||||
//
|
||||
// Replacing the sign in the format with a Z triggers
|
||||
// the ISO 8601 behavior of printing Z instead of an
|
||||
// offset for the UTC zone. Thus:
|
||||
//
|
||||
// "Z0700" Z or ±hhmm
|
||||
// "Z07:00" Z or ±hh:mm
|
||||
// "Z07" Z or ±hh
|
||||
// "Z070000" Z or ±hhmmss
|
||||
// "Z07:00:00" Z or ±hh:mm:ss
|
||||
//
|
||||
// Within the format string, the underscores in "_2" and "__2" represent spaces
|
||||
// that may be replaced by digits if the following number has multiple digits,
|
||||
// for compatibility with fixed-width Unix time formats. A leading zero represents
|
||||
// a zero-padded value.
|
||||
//
|
||||
// The formats __2 and 002 are space-padded and zero-padded
|
||||
// three-character day of year; there is no unpadded day of year format.
|
||||
//
|
||||
// A comma or decimal point followed by one or more zeros represents
|
||||
// a fractional second, printed to the given number of decimal places.
|
||||
// A comma or decimal point followed by one or more nines represents
|
||||
// a fractional second, printed to the given number of decimal places, with
|
||||
// trailing zeros removed.
|
||||
// For example "15:04:05,000" or "15:04:05.000" formats or parses with
|
||||
// millisecond precision.
|
||||
//
|
||||
// Some valid layouts are invalid time values for time.Parse, due to formats
|
||||
// such as _ for space padding and Z for zone information.
|
||||
const (
|
||||
Layout = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
|
||||
ANSIC = "Mon Jan _2 15:04:05 2006"
|
||||
UnixDate = "Mon Jan _2 15:04:05 MST 2006"
|
||||
RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
|
||||
RFC822 = "02 Jan 06 15:04 MST"
|
||||
RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone
|
||||
RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
|
||||
RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
|
||||
RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone
|
||||
RFC3339 = "2006-01-02T15:04:05Z07:00"
|
||||
RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
|
||||
Kitchen = "3:04PM"
|
||||
// Handy time stamps.
|
||||
Stamp = "Jan _2 15:04:05"
|
||||
StampMilli = "Jan _2 15:04:05.000"
|
||||
StampMicro = "Jan _2 15:04:05.000000"
|
||||
StampNano = "Jan _2 15:04:05.000000000"
|
||||
DateTime = "2006-01-02 15:04:05"
|
||||
DateOnly = "2006-01-02"
|
||||
TimeOnly = "15:04:05"
|
||||
)
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user