如果连接在 10 秒前关闭,如何取消进一步处理?
有c.Request.Context().Done()但找不到如何使用它的示例。
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
time.Sleep(10 * time.Second) // or some db operation
log.Print("Processing")
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run()
}
Run Code Online (Sandbox Code Playgroud) 我收到这些错误: -
错误:无法解析':app @ debug/compileClasspath'的依赖关系:无法解析com.android.support:appcompat-v7:27.0.0.
错误:无法解析':app @ debugAndroidTest/compileClasspath'的依赖关系:无法解析com.android.support.test:runner:1.0.1.
错误:无法解析':app @ releaseUnitTest/compileClasspath'的依赖项:无法解析junit:junit:4.12.
错误:无法解析':app @ debugAndroidTest/compileClasspath'的依赖关系:无法解析com.android.support.test.espresso:espresso-core:3.0.1.
同步卡住的屏幕截图




我是android studio plz的新手,省略了错误.
应用程序build.gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.firstapp.myapplication"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation …Run Code Online (Sandbox Code Playgroud) 我正在处理一个 RESTful API 项目,但我的代码可以使用 gorm 进行查询,我的查询是这样的countSequenceId := db.Debug().Raw("SELECT COUNT (*) FROM SMSBlast2").Scan(&smsblast1)。我有结果[1 rows affected or returned],这意味着成功计算数据库中的所有行,但我想显示结果result count = 10,但是如何?

package main
import (
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mssql"
"log"
"net/http"
"strconv"
"time"
)
type SMSBlast struct {
SequenceID int `gorm:"primary_key";column:"SequenceID"`
MobilePhone string `gorm:"column:MobilePhone"`
Output string `gorm:"column:Output"`
WillBeSentDate *time.Time `gorm:"column:WillBeSentDate"`
SentDate *time.Time `gorm:"column:SentDate"`
Status *string `gorm:"column:Status"`
DtmUpd time.Time `gorm:"column:DtmUpd"`
}
func (SMSBlast) TableName() string {
return "SMSBlast2"
}
func allSMSBlasts(w http.ResponseWriter, r *http.Request){
db, …Run Code Online (Sandbox Code Playgroud)