小编Aym*_*rif的帖子

无法在 Golang 中导入本地模块

我正在尝试导入本地模块,但无法使用go mod. 我最初使用构建我的项目go mod init github.com/AP/Ch2-GOMS

\n

请注意,我的环境是go1.14,并且我使用 VSCode 作为编辑器。

\n

这是我的文件夹结构

\n
Ch2-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代码:

\n
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.

\n

go build生成的go.mod内容:

\n
module github.com/AP/Ch2-GOMS\ngo …
Run Code Online (Sandbox Code Playgroud)

import module go go-modules

23
推荐指数
2
解决办法
5万
查看次数

application/vnd.github+json 媒体类型是什么?

我正在浏览Github REST API v3 文档并找到媒体类型application/vnd.github+json。我熟悉传统媒体类型,例如application/jsonapplication/xml

似乎与 OpenAPI 3 规范有关。如果我要创建自己的媒体类型,我将如何为新团队创建一个可供其他团队使用的媒体类型?

media-type github-api

7
推荐指数
1
解决办法
6400
查看次数

带有正则表达式的电话号码(加号和空格)

我试图用正则表达式来捕捉所有这些数字,但我找不到模式。

数字标准:

  1. 数字可以以“00”开头
  2. 数字可以以“+”开头
  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)

谢谢。

javascript regex

6
推荐指数
1
解决办法
100
查看次数

IntelliJ 中的 Gradle 任务 `bootrun` 设置

我在跑步 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)

java gradle build.gradle gradle-plugin

6
推荐指数
1
解决办法
1477
查看次数

具有动态和静态属性的接口

我有一个关于更动态的接口的问题,其中动态和静态属性可以一起使用 - 即使它们是不同的类型。这可能吗?如果是的话,这还有什么意义吗?

假设我想要这样的东西。

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)

非常感谢任何建议:)

typescript

2
推荐指数
1
解决办法
446
查看次数