我正在尝试将类型转换primitive.ObjectID为stringGo 中的类型。我正在使用mongo-driverfrom go.mongodb.org/mongo-driver.
我尝试使用类型断言
mongoId := mongoDoc["_id"];
stringObjectID := mongoId.(string)
Run Code Online (Sandbox Code Playgroud)
哪个 VSCode 接受。代码被编译,当它到达这个特定的代码行时,它会抛出这个错误
panic: interface conversion: interface {} is primitive.ObjectID, not string
Run Code Online (Sandbox Code Playgroud)