dongliangkeng1056 2017-03-20 11:44
浏览 181
已采纳

如何使用Golang为Firebase创建推送ID?

i want to push a map to firebase with an id (eg:-KfKoScgRhylaLjQlK-y)

fitToWorkMap := make(map[string]models.TaskFitToWork)
    fitToWorkForTask :=models.TaskFitToWork{}
    for i := 0; i < len(FitToWorkSlice); i++ {
        fitToWorkForTask.Info =FitToWorkSlice[i]
        fitToWorkForTask.DateOfCreation =time.Now().Unix()
        fitToWorkForTask.Status = helpers.StatusPending

        fitToWorkMap["fgsgdsfn+'i'"] = fitToWorkForTask
    }
    task.FitToWork = fitToWorkMap

here fitToWorkMap is a map .i want to generate a key for this map

  • 写回答

1条回答 默认 最新

  • dpwh11290 2017-03-20 14:16
    关注

    Those keys starting with -K are called push IDs and they are automatically generated by Firebase:

    There is no Firebase SDK for Go and uses the REST API to interact with the Firebase Database. That means that it only generates a push ID when it POSTs a new node to the database. I don't know of any library for Go to generate Firebase push IDs client-side.

    But luckily the keys are quite well documented in a blog post. The code for a JavaScript implementation of generatePushID() is also available, so you could port that over to Go.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题