conf

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 14 Imported by: 84

Documentation

Overview

Package conf includes configurations related manipulations.

Index

Constants

View Source
const (
	// PathSeparator holds the OS-specific path separator.
	PathSeparator = string(os.PathSeparator)
	// PathListSeparator holds the OS-specific path list separator.
	PathListSeparator = string(os.PathListSeparator)

	// WideVersion holds the current Wide's version.
	WideVersion = "1.5.3"
	// CodeMirrorVer holds the current editor version.
	CodeMirrorVer = "5.1"
	// UserAgent represents HTTP client user agent.
	UserAgent = "Wide/" + WideVersion + "; +https://github.com/b3log/wide"

	HelloWorld = `package main

import "fmt"

func main() {
	fmt.Println("Hello, 世界")
}
`
)
View Source
const DockerImageGo = "golang"

Docker image to run user's program

Variables

View Source
var Docker bool

Indicates whether Docker is available.

View Source
var Users []*User

configurations of users.

View Source
var Wide *conf

Wide configurations.

Functions

func CreateWorkspaceDir

func CreateWorkspaceDir(path string)

CreateWorkspaceDir creates (if not exists) directories on the path.

  1. root directory:{path}
  2. src directory: {path}/src
  3. package directory: {path}/pkg
  4. binary directory: {path}/bin

func FixedTimeCheckEnv

func FixedTimeCheckEnv()

FixedTimeCheckEnv checks Wide runtime enviorment periodically (7 minutes).

Exits process if found fatal issues (such as not found $GOPATH), Notifies user by notification queue if found warning issues (such as not found gocode).

func GetEditorThemes

func GetEditorThemes() []string

GetEditorThemes gets the names of editor themes.

func GetGoFmt

func GetGoFmt(userId string) string

GetGoFmt gets the path of Go format tool, returns "gofmt" if not found "goimports".

func GetOwner

func GetOwner(path string) string

GetOwner gets the user the specified path belongs to. Returns "" if not found.

func GetThemes

func GetThemes() []string

GetThemes gets the names of themes.

func GetUserWorkspace

func GetUserWorkspace(userId string) string

GetUserWorkspace gets workspace path with the specified user id, returns "" if not found.

func Load

func Load(confPath, confData, confServer, confLogLevel string)

Load loads the Wide configurations from wide.json and users' configurations from users/{userId}.json.

func UpdateCustomizedConf

func UpdateCustomizedConf(userId string)

UpdateCustomizedConf creates (if not exists) or updates user customized configuration files.

  1. /static/users/{userId}/style.css

Types

type LatestSessionContent

type LatestSessionContent struct {
	FileTree    []string `json:"fileTree"`    // paths of expanding nodes of file tree
	Files       []string `json:"files"`       // paths of files of opening editor tabs
	CurrentFile string   `json:"currentFile"` // path of file of the current focused editor tab
	Layout      *Layout  `json:"layout"`      // UI Layout
}

LatestSessionContent represents the latest session content.

type Layout

type Layout struct {
	Side      *Panel `json:"side"`      // Side panel
	SideRight *Panel `json:"sideRight"` // Right-Side panel
	Bottom    *Panel `json:"bottom"`    // Bottom panel
}

Layout represents the UI layout.

type Panel

type Panel struct {
	State string `json:"state"` // panel state, "min"/"max"/"normal"
	Size  uint16 `json:"size"`  // panel size
}

Panel represents a UI panel.

type User

type User struct {
	Id                    string
	Name                  string
	Avatar                string
	Workspace             string // the GOPATH of this user (maybe contain several paths splitted by os.PathListSeparator)
	Locale                string
	GoFormat              string
	GoBuildArgsForLinux   string
	GoBuildArgsForWindows string
	GoBuildArgsForDarwin  string
	FontFamily            string
	FontSize              string
	Theme                 string
	Keymap                string // wide/vim
	Created               int64  // user create time in unix nano
	Updated               int64  // preference update time in unix nano
	Lived                 int64  // the latest session activity in unix nano
	Editor                *editor
	LatestSessionContent  *LatestSessionContent
}

User configuration.

func GetUser

func GetUser(id string) *User

GetUser gets configuration of the user specified by the given user id, returns nil if not found.

func NewUser

func NewUser(id, name, avatar, workspace string) *User

NewUser creates a user with the specified username and workspace.

func (*User) BuildArgs

func (u *User) BuildArgs(os string) []string

BuildArgs get build args with the specified os.

func (*User) Save

func (u *User) Save() bool

Save saves the user's configurations in conf/users/{userId}.json.

func (*User) WorkspacePath

func (u *User) WorkspacePath() string

WorkspacePath gets workspace path of the user.

Compared to the use of Wide.Workspace, this function will be processed as follows:

  1. Replace {WD} variable with the actual directory path
  2. Replace ${GOPATH} with enviorment variable GOPATH
  3. Replace "/" with "\\" (Windows)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL