我正在尝试导入本地模块,但无法使用go mod
. 我最初使用构建我的项目go mod init github.com/AP/Ch2-GOMS
请注意,我的环境是go1.14
,并且我使用 VSCode 作为编辑器。
这是我的文件夹结构
\nCh2-GOMS\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 go.mod\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 handlers\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 hello.go\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.go\n
Run Code Online (Sandbox Code Playgroud)\n我的main.go
代码:
package main\n\nimport (\n "log"\n "net/http"\n "os"\n\n "github.com/AP/Ch2-GOMS/handlers" // This gives "could not import github.com/AP/Ch2-GOMS/handlers" lint error\n)\n\nfunc main() {\n\n l := log.New(os.Stdout, "product-api", log.LstdFlags)\n hh := handlers.NewHello(l)\n\n sm := http.NewServeMux()\n sm.Handle("/", hh)\n\n http.ListenAndServe(":9090", nil)\n} \n
Run Code Online (Sandbox Code Playgroud)\n我看不到本地模块的自动完成功能,例如handlers.NewHello
.
go build
生成的go.mod
内容:
module github.com/AP/Ch2-GOMS\ngo …
Run Code Online (Sandbox Code Playgroud) 我正在浏览Github REST API v3 文档并找到媒体类型application/vnd.github+json
。我熟悉传统媒体类型,例如application/json
,application/xml
。
似乎与 OpenAPI 3 规范有关。如果我要创建自己的媒体类型,我将如何为新团队创建一个可供其他团队使用的媒体类型?
我试图用正则表达式来捕捉所有这些数字,但我找不到模式。
数字标准:
可能是在电话号码之前或之后,您有文字。
正则表达式:
\b[\+]?[(]?[0-9]{2,6}[)]?[-\s\.]?[-\s\/\.0-9]{3,15}\b
Run Code Online (Sandbox Code Playgroud)
示例电话号码:
00491234567890
+491234567890
0123-4567890
0123 4567 789
0123 456 7890
0123 45 67 789
+490123 4567 789
+490123 456 7890
+49 123 45 67 789
123 4567 789
123 456 7890
123 45 67 789
+49 1234567890
+491234567890
0049 1234567890
0049 1234 567 890
(0049)1234567890
(+49)1234567890
(0049) 1234567890
(+49) 1234567890
text text (0049) 1234567890 text text
text text (+49) 1234567890 text text
Run Code Online (Sandbox Code Playgroud)
谢谢。
我在跑步 gradle bootRun
gradle bootRun --args='--spring.profiles.active=local' --stacktrace
Run Code Online (Sandbox Code Playgroud)
我得到一个 CreateProcess error=206, The filename or extension is too long exception
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :bootRun FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> A problem occurred starting process 'command 'C:\JDK8\jdk1.8.0_111\bin\java.exe''
* Try:
Run with --info or --debug option to get more log output. Run with --scan to …
Run Code Online (Sandbox Code Playgroud) 我有一个关于更动态的接口的问题,其中动态和静态属性可以一起使用 - 即使它们是不同的类型。这可能吗?如果是的话,这还有什么意义吗?
假设我想要这样的东西。
type MyCustomType = {
foo: string;
};
export interface MyInterface {
[key: string]: MyCustomType;
bar: string;
};
Run Code Online (Sandbox Code Playgroud)
我想确保某个 prop (我事先不知道其名称)指向 type 的值MyCustomType
。我确实知道其中的其余属性MyInterface
的名称,并且它们指向其他类型。
上面的代码会导致以下错误:
Property 'bar' of type 'string' is not assignable to string index type MyCustomType.
Run Code Online (Sandbox Code Playgroud)
我可以通过使用交集(如下例所示)来解决这个问题,或者any
但是..这也会影响我的动态道具并破坏其类型的保证。
export interface MyInterface {
[key: string]: MyCustomType | string;
bar: string;
};
Run Code Online (Sandbox Code Playgroud)
非常感谢任何建议:)
build.gradle ×1
github-api ×1
go ×1
go-modules ×1
gradle ×1
import ×1
java ×1
javascript ×1
media-type ×1
module ×1
regex ×1
typescript ×1