我有一个执行以下操作的 Firebase 云函数:
const firestore = require('firebase-admin')
const functions = require('firebase-functions')
const regex = require('../../utils/regex')
exports = module.exports = functions.https.onCall((data, context) => {
if (!context.auth) {
throw new functions.https.HttpsError('failed-precondition', 'The function must be called while authenticated.')
}
if (!data['displayName']) {
throw new functions.https.HttpsError('failed-precondition', 'An display name must be provided.')
}
if (!regex.noSpecialCharactersExceptSpace.test(data['displayName'])) {
throw new functions.https.HttpsError('input-validation-failed', 'Your display name cannot have special characters in it.')
}
return firestore.firestore().collection('profiles').doc(context.auth.uid)
.update({
displayName: data['displayName']
})
.then(() => {
console.info('Successful public profile update user='+ …Run Code Online (Sandbox Code Playgroud) javascript firebase google-cloud-functions google-cloud-firestore
背景:
规格:
firebase.functions().httpsCallablefunctions.https.onCall题:
如何firebase.functions().httpsCallable提交文件functions.https.onCall?
先感谢您。
ABC。
我们已经构建了一个我们很多人都使用的Go包.
它是使用标准import ("package-name")方法导入的.
但是在编译时,我们所有的实用程序,包括非常小的实用程序,最终都是非常大的二进制文件.
我们已经提取了实用程序中的所有字符串,并发现整个包正在编译到每个实用程序中.包括那些实用程序未使用的函数.
编辑1:
感谢回答这个问题的人们.
这是我们所看到的:
main.go
package main
import "play/subplay"
func main() {
subplay.A()
}
Run Code Online (Sandbox Code Playgroud)
播放/ subplay.go
package subplay
func A() {
fmt.Printf("this is function A()")
}
func B() {
fmt.Printf("secret string")
}
Run Code Online (Sandbox Code Playgroud)
函数B()永远不会被调用.然而,在构建二进制文件之后,我们在main.exe中找到字符串"secret string".
如何在编译时从Go程序中删除未使用的代码?