duanjue6575 2017-01-12 20:08
浏览 28

在结构golang中按一个字符串组织一个字符串映射

I have a structure of notifications, which looks like:

type Notification struct {
    ID          bson.ObjectId  //unique id for this notification
    ClientID    bson.ObjectId //this identifies the client attached to
    Description string   //notification message
    Date        string   //date using time.Now()
}

So in practice, I have a jumbled collection of data, for example: "User1 has been invited", "User3 has accepted their invite", "User2 has made a payment", "User3 has made a payment", "User1 has accepted their invite", etc, etc...

QUESTION: I don't know how many clients I may have at one time, but I want to be able to search the struct and find out how many unique ClientID's I have. My objective is to start creating a dynamic map where I'm attaching all of the notifications to their individual clients.

The final goal is to be able to pass to the front end (GoLang Template) a display report that looks like this?

ClientID(User1): "User1 has been invited", "User1 has accepted their invite"

ClientID(User2): "User2 has made a payment"

ClientID(User3): "User3 has accepted their invite", "User3 has made a payment"

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀